{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "157489e8",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy import *\n",
    "from sympy.abc import x,y,z,m,n,k\n",
    "from sympy.stats import FiniteRV,E,P"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9dba3802",
   "metadata": {},
   "outputs": [],
   "source": [
    "f=Function(\"f\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "6ce3b1cf",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.calculus.util import function_range,continuous_domain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "a4afb48c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "f537cb7e",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/home/huang/python_code',\n",
       " '/home/huang/anaconda3/lib/python39.zip',\n",
       " '/home/huang/anaconda3/lib/python3.9',\n",
       " '/home/huang/anaconda3/lib/python3.9/lib-dynload',\n",
       " '',\n",
       " '/home/huang/anaconda3/lib/python3.9/site-packages',\n",
       " '/home/huang/Documents/packaging_tutorial/src']"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "311251e1",
   "metadata": {},
   "outputs": [],
   "source": [
    "sys.path.append(\"/home/huang/Documents/packaging_tutorial/src\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3481ed18",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from sympy.abc import a,b,c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e65a0388",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/home/huang/python_code',\n",
       " '/home/huang/anaconda3/lib/python39.zip',\n",
       " '/home/huang/anaconda3/lib/python3.9',\n",
       " '/home/huang/anaconda3/lib/python3.9/lib-dynload',\n",
       " '',\n",
       " '/home/huang/anaconda3/lib/python3.9/site-packages',\n",
       " '/home/huang/Documents/packaging_tutorial/src']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "fc486113",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The autoreload extension is already loaded. To reload it, use:\n",
      "  %reload_ext autoreload\n"
     ]
    }
   ],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "63163df8",
   "metadata": {},
   "outputs": [],
   "source": [
    "from function_calculator_package.extreme_points import *\n",
    "%aimport function_calculator_package.extreme_points"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "334a018f",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function trigsimp in module sympy.simplify.trigsimp:\n",
      "\n",
      "trigsimp(expr, **opts)\n",
      "    reduces expression by using known trig identities\n",
      "    \n",
      "    Explanation\n",
      "    ===========\n",
      "    \n",
      "    method:\n",
      "    - Determine the method to use. Valid choices are 'matching' (default),\n",
      "    'groebner', 'combined', and 'fu'. If 'matching', simplify the\n",
      "    expression recursively by targeting common patterns. If 'groebner', apply\n",
      "    an experimental groebner basis algorithm. In this case further options\n",
      "    are forwarded to ``trigsimp_groebner``, please refer to its docstring.\n",
      "    If 'combined', first run the groebner basis algorithm with small\n",
      "    default parameters, then run the 'matching' algorithm. 'fu' runs the\n",
      "    collection of trigonometric transformations described by Fu, et al.\n",
      "    (see the `fu` docstring).\n",
      "    \n",
      "    \n",
      "    Examples\n",
      "    ========\n",
      "    \n",
      "    >>> from sympy import trigsimp, sin, cos, log\n",
      "    >>> from sympy.abc import x\n",
      "    >>> e = 2*sin(x)**2 + 2*cos(x)**2\n",
      "    >>> trigsimp(e)\n",
      "    2\n",
      "    \n",
      "    Simplification occurs wherever trigonometric functions are located.\n",
      "    \n",
      "    >>> trigsimp(log(e))\n",
      "    log(2)\n",
      "    \n",
      "    Using `method=\"groebner\"` (or `\"combined\"`) might lead to greater\n",
      "    simplification.\n",
      "    \n",
      "    The old trigsimp routine can be accessed as with method 'old'.\n",
      "    \n",
      "    >>> from sympy import coth, tanh\n",
      "    >>> t = 3*tanh(x)**7 - 2/coth(x)**7\n",
      "    >>> trigsimp(t, method='old') == t\n",
      "    True\n",
      "    >>> trigsimp(t)\n",
      "    tanh(x)**7\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(trigsimp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ed78fd0d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{\\left(1 - \\sin{\\left(2 x \\right)}\\right) \\sin{\\left(x \\right)}}{\\sin{\\left(x \\right)} - \\cos{\\left(x \\right)}}$"
      ],
      "text/plain": [
       "(1 - sin(2*x))*sin(x)/(sin(x) - cos(x))"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=sin(x)*(1-sin(2*x))/(sin(x)-cos(x))\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "7ffebe20",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function expand_trig in module sympy.core.function:\n",
      "\n",
      "expand_trig(expr, deep=True)\n",
      "    Wrapper around expand that only uses the trig hint.  See the expand\n",
      "    docstring for more information.\n",
      "    \n",
      "    Examples\n",
      "    ========\n",
      "    \n",
      "    >>> from sympy import expand_trig, sin\n",
      "    >>> from sympy.abc import x, y\n",
      "    >>> expand_trig(sin(x+y)*(x+y))\n",
      "    (x + y)*(sin(x)*cos(y) + sin(y)*cos(x))\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(expand_trig)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "32b2cf81",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{\\sin{\\left(2 x + \\frac{\\pi}{4} \\right)}}{2} + \\frac{\\sqrt{2}}{4}$"
      ],
      "text/plain": [
       "sin(2*x + pi/4)/2 + sqrt(2)/4"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trigsimp(cos(x)*sin(x+pi/4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3e96f54d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\sin^{2}{\\left(x \\right)} + \\sqrt{3} \\cos{\\left(x \\right)} - \\frac{3}{4}$"
      ],
      "text/plain": [
       "sin(x)**2 + sqrt(3)*cos(x) - 3/4"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sin(x)**2+sqrt(3)*cos(x)-Rational(3,4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "5eec7ec1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\sin^{2}{\\left(x \\right)} + \\sqrt{3} \\cos{\\left(x \\right)} - \\frac{3}{4}$"
      ],
      "text/plain": [
       "sin(x)**2 + sqrt(3)*cos(x) - 3/4"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(sin(x)**2+sqrt(3)*cos(x)-Rational(3,4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "fde9a59d",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{- i \\left(i \\left(2 n \\pi + \\operatorname{atan}{\\left(\\frac{8 \\operatorname{re}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)} + 3 \\sqrt{3}}{3 - 8 \\operatorname{im}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)}} \\right)}\\right) + \\log{\\left(\\sqrt{\\frac{12 \\sqrt{3} \\operatorname{re}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)}}{25} + \\frac{16 \\left(\\operatorname{re}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)}\\right)^{2}}{25} + \\frac{9}{25} - \\frac{12 \\operatorname{im}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)}}{25} + \\frac{16 \\left(\\operatorname{im}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)}\\right)^{2}}{25}} \\right)}\\right)\\; \\middle|\\; n \\in \\mathbb{Z}\\right\\} \\cup \\left\\{- i \\left(i \\left(2 n \\pi + \\operatorname{atan}{\\left(\\frac{- 8 \\operatorname{re}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)} + 3 \\sqrt{3}}{8 \\operatorname{im}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)} + 3} \\right)} + \\pi\\right) + \\log{\\left(\\sqrt{\\frac{12 \\operatorname{im}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)}}{25} + \\frac{16 \\left(\\operatorname{re}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)}\\right)^{2}}{25} + \\frac{9}{25} - \\frac{12 \\sqrt{3} \\operatorname{re}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)}}{25} + \\frac{16 \\left(\\operatorname{im}{\\left(\\sqrt{- \\sqrt[3]{-1}} e^{- \\frac{i \\pi}{3}}\\right)}\\right)^{2}}{25}} \\right)}\\right)\\; \\middle|\\; n \\in \\mathbb{Z}\\right\\}$"
      ],
      "text/plain": [
       "Union(ImageSet(Lambda(_n, -I*(I*(2*_n*pi + atan((8*re(sqrt(-(-1)**(1/3))*exp(-I*pi/3)) + 3*sqrt(3))/(3 - 8*im(sqrt(-(-1)**(1/3))*exp(-I*pi/3))))) + log(sqrt(12*sqrt(3)*re(sqrt(-(-1)**(1/3))*exp(-I*pi/3))/25 + 16*re(sqrt(-(-1)**(1/3))*exp(-I*pi/3))**2/25 + 9/25 - 12*im(sqrt(-(-1)**(1/3))*exp(-I*pi/3))/25 + 16*im(sqrt(-(-1)**(1/3))*exp(-I*pi/3))**2/25)))), Integers), ImageSet(Lambda(_n, -I*(I*(2*_n*pi + atan((-8*re(sqrt(-(-1)**(1/3))*exp(-I*pi/3)) + 3*sqrt(3))/(8*im(sqrt(-(-1)**(1/3))*exp(-I*pi/3)) + 3)) + pi) + log(sqrt(12*im(sqrt(-(-1)**(1/3))*exp(-I*pi/3))/25 + 16*re(sqrt(-(-1)**(1/3))*exp(-I*pi/3))**2/25 + 9/25 - 12*sqrt(3)*re(sqrt(-(-1)**(1/3))*exp(-I*pi/3))/25 + 16*im(sqrt(-(-1)**(1/3))*exp(-I*pi/3))**2/25)))), Integers))"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(Eq(cos(pi/3-x),Rational(3,5)),x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "650ec8ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\emptyset$"
      ],
      "text/plain": [
       "EmptySet"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset((a-2)**2<=-a**2+1,a,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "9f2ded60",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\\\infty'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "latex(oo)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "87b567ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3%2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "74254594",
   "metadata": {},
   "outputs": [],
   "source": [
    "def H(n):\n",
    "    if n%2==1:\n",
    "        return n\n",
    "    else:\n",
    "        while(n%2==0):\n",
    "            n/=S(2)\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "7a0a8d45",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 7$"
      ],
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "H(14)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "d2b7aa31",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 1$"
      ],
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "H(2**4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "39196306",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "sum=0\n",
    "for i in range(1,2**15):\n",
    "    # print(H(i))\n",
    "    sum+=H(i)\n",
    "print(sum-(4**15-1)/3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "01925e76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{48 x^{2}}{8 x^{2} - 1}$"
      ],
      "text/plain": [
       "48*x**2/(8*x**2 - 1)"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "48*x**2/(8*x**2-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "a28822ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{72 x^{2} + 8}{8 x^{2} - 1}$"
      ],
      "text/plain": [
       "(72*x**2 + 8)/(8*x**2 - 1)"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "8*(9*x**2+1)/(8*x**2-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "3de3efdb",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=(48*x**2/(8*x**2-1))**2-4*(8*(9*x**2+1)/(8*x**2-1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "023e47cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{2304 x^{4}}{\\left(8 x^{2} - 1\\right)^{2}} - \\frac{4 \\cdot \\left(72 x^{2} + 8\\right)}{8 x^{2} - 1}$"
      ],
      "text/plain": [
       "2304*x**4/(8*x**2 - 1)**2 - 4*(72*x**2 + 8)/(8*x**2 - 1)"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "e2de52cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 4 \\sqrt{2} \\sqrt{\\frac{x^{2} + 1}{64 x^{4} - 16 x^{2} + 1}}$"
      ],
      "text/plain": [
       "4*sqrt(2)*sqrt((x**2 + 1)/(64*x**4 - 16*x**2 + 1))"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(sqrt(expr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "47545af6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{\\frac{4 \\sqrt{7}}{7}\\right\\}$"
      ],
      "text/plain": [
       "{4*sqrt(7)/7}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(Eq(sqrt(x**2-1)*Rational(2,3),x/2),x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "834370bc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{\\log{\\left(x + 1 \\right)}}{\\log{\\left(x \\right)}}$"
      ],
      "text/plain": [
       "log(x + 1)/log(x)"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=log(x+1,x)\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "a80c7298",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{1}{\\left(x + 1\\right) \\log{\\left(x \\right)}} - \\frac{\\log{\\left(x + 1 \\right)}}{x \\log{\\left(x \\right)}^{2}}$"
      ],
      "text/plain": [
       "1/((x + 1)*log(x)) - log(x + 1)/(x*log(x)**2)"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(diff(expr,x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "d6b540c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{x \\log{\\left(x \\right)} - \\left(x + 1\\right) \\log{\\left(x + 1 \\right)}}{x \\left(x + 1\\right) \\log{\\left(x \\right)}^{2}}$"
      ],
      "text/plain": [
       "(x*log(x) - (x + 1)*log(x + 1))/(x*(x + 1)*log(x)**2)"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "together(diff(expr,x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "b70154d9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{\\log{\\left(x \\right)}}{x^{2}}$"
      ],
      "text/plain": [
       "log(x)/x**2"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=ln(x)/x**2\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "1dfa1e5a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{1 - 2 \\log{\\left(x \\right)}}{x^{3}}$"
      ],
      "text/plain": [
       "(1 - 2*log(x))/x**3"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "together(diff(expr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "064445a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=(x-3)*exp(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "f6dd2cd5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'+': [Interval.open(2, oo)], '-': [Interval.open(-oo, 2)]}"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_monotonyset(expr,x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "bda54c17",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left(x - 3\\right) e^{x} + e^{x}$"
      ],
      "text/plain": [
       "(x - 3)*exp(x) + exp(x)"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(expr,x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "3ceb085e",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x + \\frac{x^{3}}{3} + \\frac{2 x^{5}}{15} + O\\left(x^{6}\\right)$"
      ],
      "text/plain": [
       "x + x**3/3 + 2*x**5/15 + O(x**6)"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "series(tan(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "92e78c22",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function function_tangent in module function_calculator_package.extreme_points:\n",
      "\n",
      "function_tangent(f, x, x_0=0, coordinate=(x, y))\n",
      "    this function will return the f(function of x)'s tangent equation at x=x_0.\n",
      "    \n",
      "    if you don't point out the the x_0,it will be 0.\n",
      "    if you don't point out the coordinate's symbols, it will be xOy coordinate.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(function_tangent)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "ceaff4ac",
   "metadata": {},
   "outputs": [],
   "source": [
    "def curvature(f,x,x0=0):\n",
    "    return abs(diff(f,x,x).subs(x,x0))/(1+(diff(f,x).subs(x,x0))**2)**(Rational(3,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "7834bd0e",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=ln(x)-cos(x-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "676f201a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 0$"
      ],
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "curvature(expr,x,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "2791850c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\sin{\\left(x - 1 \\right)} + \\frac{1}{x}$"
      ],
      "text/plain": [
       "sin(x - 1) + 1/x"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(expr,x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "3a89aa01",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\cos{\\left(x - 1 \\right)} - \\frac{1}{x^{2}}$"
      ],
      "text/plain": [
       "cos(x - 1) - 1/x**2"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff(expr,x,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "2c4fbc82",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle a x^{2} + \\left(x^{2} - 2 x + 2\\right) e^{x}$"
      ],
      "text/plain": [
       "a*x**2 + (x**2 - 2*x + 2)*exp(x)"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=a*x**2+(x**2-2*x+2)*exp(x)\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0a3f607e",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.abc import t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "c896d98d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle y = - a t^{2} + 2 a t x - t^{3} e^{t} + t^{2} x e^{t} + t^{2} e^{t} - 2 t e^{t} + 2 e^{t}$"
      ],
      "text/plain": [
       "Eq(y, -a*t**2 + 2*a*t*x - t**3*exp(t) + t**2*x*exp(t) + t**2*exp(t) - 2*t*exp(t) + 2*exp(t))"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "together(expand(function_tangent(expr,x,t)),x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "2e3a2cdf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle y = 2$"
      ],
      "text/plain": [
       "Eq(y, 2)"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(function_tangent(expr,x,0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "360c1835",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x \\left(2 a + x e^{x}\\right)$"
      ],
      "text/plain": [
       "x*(2*a + x*exp(x))"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(diff(expr,x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "86912f58",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - 3 a^{2} x - a x^{2} + \\frac{x^{3}}{3} + 1$"
      ],
      "text/plain": [
       "-3*a**2*x - a*x**2 + x**3/3 + 1"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=x**3/3-a*x**2-3*a**2*x+1\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "5b494e05",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "ename": "NotImplementedError",
     "evalue": "We haven't handle the type of diff(f)'s solveset type:\n<class 'sympy.sets.sets.Intersection'>\nplease wait.",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNotImplementedError\u001b[0m                       Traceback (most recent call last)",
      "Input \u001b[0;32mIn [104]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mfunction_monotonyset\u001b[49m\u001b[43m(\u001b[49m\u001b[43mexpr\u001b[49m\u001b[43m,\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/Documents/packaging_tutorial/src/function_calculator_package/extreme_points.py:55\u001b[0m, in \u001b[0;36mfunction_monotonyset\u001b[0;34m(f, x, interval, dir)\u001b[0m\n\u001b[1;32m     52\u001b[0m     x_list\u001b[38;5;241m.\u001b[39msort()\n\u001b[1;32m     54\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m---> 55\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin([\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWe haven\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt handle the type of diff(f)\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124ms solveset type:\u001b[39m\u001b[38;5;124m\"\u001b[39m,\u001b[38;5;28mstr\u001b[39m(set_type),\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mplease wait.\u001b[39m\u001b[38;5;124m\"\u001b[39m]))\n\u001b[1;32m     56\u001b[0m \u001b[38;5;66;03m# if the set is ImageSet or it's Union,\u001b[39;00m\n\u001b[1;32m     57\u001b[0m \u001b[38;5;66;03m# it can also work, but I don't how to \u001b[39;00m\n\u001b[1;32m     58\u001b[0m \u001b[38;5;66;03m# operate it now. \u001b[39;00m\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m     61\u001b[0m \u001b[38;5;66;03m# add the edge point to x_list\u001b[39;00m\n\u001b[1;32m     62\u001b[0m \u001b[38;5;66;03m# and add the f's value on the points\u001b[39;00m\n\u001b[1;32m     64\u001b[0m f_value_list\u001b[38;5;241m=\u001b[39m[]\n",
      "\u001b[0;31mNotImplementedError\u001b[0m: We haven't handle the type of diff(f)'s solveset type:\n<class 'sympy.sets.sets.Intersection'>\nplease wait."
     ]
    }
   ],
   "source": [
    "function_monotonyset(expr,x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "b66684e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{5 a^{3}}{3} + 1$"
      ],
      "text/plain": [
       "5*a**3/3 + 1"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,-a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "bca72724",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 1 - 9 a^{3}$"
      ],
      "text/plain": [
       "1 - 9*a**3"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,3*a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "abc4717f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}2 & 3 & 3\\\\-2 & 0 & 1\\\\-4 & 4 & 0\\\\3 & -3 & 4\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[ 2,  3, 3],\n",
       "[-2,  0, 1],\n",
       "[-4,  4, 0],\n",
       "[ 3, -3, 4]])"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P=Matrix([[2,3,3],[-2,0,1],[-4,4,0],[3,-3,4]])\n",
    "P"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "7470dc77",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & -1 & 2\\\\1 & -1 & 2\\\\1 & -1 & 2\\\\1 & -1 & 2\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[1, -1, 2],\n",
       "[1, -1, 2],\n",
       "[1, -1, 2],\n",
       "[1, -1, 2]])"
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "M_m=Matrix([[1,-1,2]*4]).reshape(4,3)\n",
    "M_m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "id": "a56a49fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 4 & 1\\\\-3 & 1 & -1\\\\-5 & 5 & -2\\\\2 & -2 & 2\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[ 1,  4,  1],\n",
       "[-3,  1, -1],\n",
       "[-5,  5, -2],\n",
       "[ 2, -2,  2]])"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P_m=P-M_m\n",
    "P_m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "761cda01",
   "metadata": {},
   "outputs": [],
   "source": [
    "n_m=Matrix([2,-1,2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "8d5b5352",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}2\\\\-1\\\\2\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[ 2],\n",
       "[-1],\n",
       "[ 2]])"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n_m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "9010194e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0\\\\-9\\\\-19\\\\10\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[  0],\n",
       "[ -9],\n",
       "[-19],\n",
       "[ 10]])"
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P_m*n_m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "84c7bd64",
   "metadata": {},
   "outputs": [],
   "source": [
    "f=Function(\"f\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "93080122",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle f{\\left(f{\\left(x \\right)} \\right)} = 4 x - 1$"
      ],
      "text/plain": [
       "Eq(f(f(x)), 4*x - 1)"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Eq(f(f(x)),4*x-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "id": "c649d033",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{y - 1}{x - 2}$"
      ],
      "text/plain": [
       "(y - 1)/(x - 2)"
      ]
     },
     "execution_count": 127,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tan_expr=(y-1)/(x-2)\n",
    "tan_expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "5817908b",
   "metadata": {},
   "outputs": [],
   "source": [
    "x1,x2,y1,y2=symbols(\"x1,x2,y1,y2\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "id": "df71c30e",
   "metadata": {},
   "outputs": [],
   "source": [
    "zero_expr=tan_expr.subs([(x,x1),(y,y1)])+tan_expr.subs([(x,x2),(y,y2)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "f702354c",
   "metadata": {},
   "outputs": [],
   "source": [
    "k,m=symbols(\"k,m\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "id": "58ebd3a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{k x_{2} + m - 1}{x_{2} - 2} + \\frac{k x_{1} + m - 1}{x_{1} - 2}$"
      ],
      "text/plain": [
       "(k*x2 + m - 1)/(x2 - 2) + (k*x1 + m - 1)/(x1 - 2)"
      ]
     },
     "execution_count": 137,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "zero_expr.subs([(y1,k*x1+m),(y2,k*x2+m)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "id": "2496834c",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=factor(expand(together(zero_expr.subs([(y1,k*x1+m),(y2,k*x2+m)])).args[2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "id": "c76b6697",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 2 k x_{1} x_{2} - 2 k x_{1} - 2 k x_{2} - 2 m^{2} + m x_{1} + m x_{2} - 4 m + 4 - \\frac{2}{2 k^{2} - 1}$"
      ],
      "text/plain": [
       "2*k*x1*x2 - 2*k*x1 - 2*k*x2 - 2*m**2 + m*x1 + m*x2 - 4*m + 4 - 2/(2*k**2 - 1)"
      ]
     },
     "execution_count": 151,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x1+x2,2*m**2+2/(2*k**2-1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "id": "b0439ed0",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=2*k*(2*m**2+2)/(2*k**2-1)+(m-1-2*k)*(-4*k*m/(2*k**2-1))-4*(m-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "id": "34b7c7ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\frac{4 k m \\left(- 2 k + m - 1\\right)}{2 k^{2} - 1} + \\frac{2 k \\left(2 m^{2} + 2\\right)}{2 k^{2} - 1} - 4 m + 4$"
      ],
      "text/plain": [
       "-4*k*m*(-2*k + m - 1)/(2*k**2 - 1) + 2*k*(2*m**2 + 2)/(2*k**2 - 1) - 4*m + 4"
      ]
     },
     "execution_count": 159,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "id": "bd96a5b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{4 \\cdot \\left(2 k^{2} + k m + k + m - 1\\right)}{2 k^{2} - 1}$"
      ],
      "text/plain": [
       "4*(2*k**2 + k*m + k + m - 1)/(2*k**2 - 1)"
      ]
     },
     "execution_count": 160,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(simplify(expr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "id": "ad3d52bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left(k + 1\\right) \\left(2 k + m - 1\\right)$"
      ],
      "text/plain": [
       "(k + 1)*(2*k + m - 1)"
      ]
     },
     "execution_count": 162,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "factor(simplify(expr).args[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "id": "6ecaf954",
   "metadata": {},
   "outputs": [],
   "source": [
    "answer=nonlinsolve([tan_expr.subs([(x,x1),(y,y1)])-sqrt(2),x1**2/2-y1**2-1],[x1,y1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "id": "448e089f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{10}{3} - \\frac{4 \\sqrt{2}}{3}$"
      ],
      "text/plain": [
       "10/3 - 4*sqrt(2)/3"
      ]
     },
     "execution_count": 166,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(list(answer)[0][0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "id": "34202cc9",
   "metadata": {},
   "outputs": [],
   "source": [
    "answer=nonlinsolve([tan_expr.subs([(x,x1),(y,y1)])+sqrt(2),x1**2/2-y1**2-1],[x1,y1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "id": "512dd08d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{\\left( \\frac{\\sqrt{2}}{2} + 2 - \\frac{\\sqrt{2} \\left(- \\frac{4 \\sqrt{2}}{3} - \\frac{5}{3}\\right)}{2}, \\  - \\frac{4 \\sqrt{2}}{3} - \\frac{5}{3}\\right)\\right\\}$"
      ],
      "text/plain": [
       "{(sqrt(2)/2 + 2 - sqrt(2)*(-4*sqrt(2)/3 - 5/3)/2, -4*sqrt(2)/3 - 5/3)}"
      ]
     },
     "execution_count": 169,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "id": "62f39e5c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{4 \\sqrt{2}}{3} + \\frac{10}{3}$"
      ],
      "text/plain": [
       "4*sqrt(2)/3 + 10/3"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(list(answer)[0][0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "id": "1fe87e22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle a x - a + \\frac{x^{3}}{3} - x^{2}$"
      ],
      "text/plain": [
       "a*x - a + x**3/3 - x**2"
      ]
     },
     "execution_count": 172,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=Rational(1,3)*x**3-x**2+a*x-a\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "id": "782620c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle a x^{2} + a x + \\frac{x^{3}}{3} - 2 x$"
      ],
      "text/plain": [
       "a*x**2 + a*x + x**3/3 - 2*x"
      ]
     },
     "execution_count": 173,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g_expr=expr+diff(expr,x)+a*x**2\n",
    "g_expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "id": "0dedec67",
   "metadata": {},
   "outputs": [],
   "source": [
    "answer=Eq(y**2,4*x).subs(y,Rational(1,2)*(x+1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "id": "633f11b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{x^{2}}{4} + \\frac{x}{2} + \\frac{1}{4} = 4 x$"
      ],
      "text/plain": [
       "Eq(x**2/4 + x/2 + 1/4, 4*x)"
      ]
     },
     "execution_count": 177,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 182,
   "id": "993630c6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\frac{\\log{\\left(x^{2} - 2 x - 3 \\right)}}{\\log{\\left(2 \\right)}}$"
      ],
      "text/plain": [
       "-log(x**2 - 2*x - 3)/log(2)"
      ]
     },
     "execution_count": 182,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=log(x**2-2*x-3,Rational(1,2))\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "id": "3e403980",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "Invalid comparison of non-real -(log(4) + I*pi)/log(2)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[0;32mIn [184]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mfunction_monotonyset\u001b[49m\u001b[43m(\u001b[49m\u001b[43mexpr\u001b[49m\u001b[43m,\u001b[49m\u001b[43mx\u001b[49m\u001b[43m,\u001b[49m\u001b[43mReals\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/Documents/packaging_tutorial/src/function_calculator_package/extreme_points.py:78\u001b[0m, in \u001b[0;36mfunction_monotonyset\u001b[0;34m(f, x, interval, dir)\u001b[0m\n\u001b[1;32m     75\u001b[0m     f_value_list\u001b[38;5;241m.\u001b[39mappend(interval_sup_value)\n\u001b[1;32m     77\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mlen\u001b[39m(x_list)\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m):\n\u001b[0;32m---> 78\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m(\u001b[43mf_value_list\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m<\u001b[39;49m\u001b[43mf_value_list\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m):\n\u001b[1;32m     79\u001b[0m         increase_sets\u001b[38;5;241m.\u001b[39mappend(Interval\u001b[38;5;241m.\u001b[39mopen(x_list[i],x_list[i\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m1\u001b[39m]))\n\u001b[1;32m     80\u001b[0m     \u001b[38;5;28;01melse\u001b[39;00m:\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/core/decorators.py:236\u001b[0m, in \u001b[0;36m_SympifyWrapper.make_wrapped.<locals>._func\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m    234\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(other, expectedcls):\n\u001b[1;32m    235\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m retval\n\u001b[0;32m--> 236\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mother\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/core/expr.py:370\u001b[0m, in \u001b[0;36mExpr.__lt__\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m    367\u001b[0m \u001b[38;5;129m@sympify_return\u001b[39m([(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mother\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mExpr\u001b[39m\u001b[38;5;124m'\u001b[39m)], \u001b[38;5;28mNotImplemented\u001b[39m)\n\u001b[1;32m    368\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__lt__\u001b[39m(\u001b[38;5;28mself\u001b[39m, other):\n\u001b[1;32m    369\u001b[0m     \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mrelational\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m StrictLessThan\n\u001b[0;32m--> 370\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mStrictLessThan\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mother\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/core/relational.py:834\u001b[0m, in \u001b[0;36m_Inequality.__new__\u001b[0;34m(cls, lhs, rhs, **options)\u001b[0m\n\u001b[1;32m    832\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m me \u001b[38;5;129;01min\u001b[39;00m (lhs, rhs):\n\u001b[1;32m    833\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m me\u001b[38;5;241m.\u001b[39mis_extended_real \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m:\n\u001b[0;32m--> 834\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid comparison of non-real \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m%\u001b[39m me)\n\u001b[1;32m    835\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m me \u001b[38;5;129;01mis\u001b[39;00m S\u001b[38;5;241m.\u001b[39mNaN:\n\u001b[1;32m    836\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid NaN comparison\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "\u001b[0;31mTypeError\u001b[0m: Invalid comparison of non-real -(log(4) + I*pi)/log(2)"
     ]
    }
   ],
   "source": [
    "function_monotonyset(expr,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "id": "193244a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'+': [], '-': Interval(-oo, oo)}"
      ]
     },
     "execution_count": 185,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_monotonyset((2**x-1)/(2**x+1),x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "1fb2b15d",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.calculus.util import function_range"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "id": "ad541669",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "ename": "NotImplementedError",
     "evalue": "Unable to find critical points for floor((2*3**x - 1)/(3**x + 1))",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNotImplementedError\u001b[0m                       Traceback (most recent call last)",
      "Input \u001b[0;32mIn [189]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mfunction_range\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfloor\u001b[49m\u001b[43m(\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mx\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mx\u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43mx\u001b[49m\u001b[43m,\u001b[49m\u001b[43mReals\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/calculus/util.py:200\u001b[0m, in \u001b[0;36mfunction_range\u001b[0;34m(f, symbol, domain)\u001b[0m\n\u001b[1;32m    197\u001b[0m solution \u001b[38;5;241m=\u001b[39m solveset(f\u001b[38;5;241m.\u001b[39mdiff(symbol), symbol, interval)\n\u001b[1;32m    199\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m iterable(solution):\n\u001b[0;32m--> 200\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m(\n\u001b[1;32m    201\u001b[0m             \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mUnable to find critical points for \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mformat(f))\n\u001b[1;32m    202\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(solution, ImageSet):\n\u001b[1;32m    203\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m(\n\u001b[1;32m    204\u001b[0m             \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mInfinite number of critical points for \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mformat(f))\n",
      "\u001b[0;31mNotImplementedError\u001b[0m: Unable to find critical points for floor((2*3**x - 1)/(3**x + 1))"
     ]
    }
   ],
   "source": [
    "function_range(floor((2*3**x-1)/(3**x+1)),x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "id": "7c616b03",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "The computation had not completed because of the undecidable set membership is found in every candidates.",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[0;32mIn [195]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mfunction_range\u001b[49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43mx\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mm\u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43mx\u001b[49m\u001b[43m,\u001b[49m\u001b[43mInterval\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mLopen\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/calculus/util.py:208\u001b[0m, in \u001b[0;36mfunction_range\u001b[0;34m(f, symbol, domain)\u001b[0m\n\u001b[1;32m    203\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m(\n\u001b[1;32m    204\u001b[0m             \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mInfinite number of critical points for \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mformat(f))\n\u001b[1;32m    206\u001b[0m critical_points \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m solution\n\u001b[0;32m--> 208\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m critical_point \u001b[38;5;129;01min\u001b[39;00m critical_points:\n\u001b[1;32m    209\u001b[0m     vals \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m FiniteSet(f\u001b[38;5;241m.\u001b[39msubs(symbol, critical_point))\n\u001b[1;32m    211\u001b[0m left_open, right_open \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m, \u001b[38;5;28;01mFalse\u001b[39;00m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/sets/sets.py:1439\u001b[0m, in \u001b[0;36mIntersection.__iter__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m   1437\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m candidates:\n\u001b[1;32m   1438\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNone of the constituent sets are iterable\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m-> 1439\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\n\u001b[1;32m   1440\u001b[0m     \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThe computation had not completed because of the \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m   1441\u001b[0m     \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mundecidable set membership is found in every candidates.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "\u001b[0;31mTypeError\u001b[0m: The computation had not completed because of the undecidable set membership is found in every candidates."
     ]
    }
   ],
   "source": [
    "function_range(x**2+x*m+2,x,Interval.Lopen(0,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "id": "e9c532b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=2*(log(x,4)-1)*(log(x,4)+Rational(1,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 209,
   "id": "e2c45396",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\frac{9}{8}$"
      ],
      "text/plain": [
       "-9/8"
      ]
     },
     "execution_count": 209,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify((function_range(expr,x,Interval(1,16))).start)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 210,
   "id": "5cac04f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 5$"
      ],
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 210,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify((function_range(expr,x,Interval(1,16))).end)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 211,
   "id": "97c1b40d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left(0, \\frac{1}{4}\\right) \\cup \\left(8, \\infty\\right)$"
      ],
      "text/plain": [
       "Union(Interval.open(0, 1/4), Interval.open(8, oo))"
      ]
     },
     "execution_count": 211,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(expr>2,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "id": "c7daff83",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class Interval in module sympy.sets.sets:\n",
      "\n",
      "class Interval(Set)\n",
      " |  Interval(start, end, left_open=False, right_open=False)\n",
      " |  \n",
      " |  Represents a real interval as a Set.\n",
      " |  \n",
      " |  Usage:\n",
      " |      Returns an interval with end points ``start`` and ``end``.\n",
      " |  \n",
      " |      For ``left_open=True`` (default ``left_open`` is ``False``) the interval\n",
      " |      will be open on the left. Similarly, for ``right_open=True`` the interval\n",
      " |      will be open on the right.\n",
      " |  \n",
      " |  Examples\n",
      " |  ========\n",
      " |  \n",
      " |  >>> from sympy import Symbol, Interval\n",
      " |  >>> Interval(0, 1)\n",
      " |  Interval(0, 1)\n",
      " |  >>> Interval.Ropen(0, 1)\n",
      " |  Interval.Ropen(0, 1)\n",
      " |  >>> Interval.Ropen(0, 1)\n",
      " |  Interval.Ropen(0, 1)\n",
      " |  >>> Interval.Lopen(0, 1)\n",
      " |  Interval.Lopen(0, 1)\n",
      " |  >>> Interval.open(0, 1)\n",
      " |  Interval.open(0, 1)\n",
      " |  \n",
      " |  >>> a = Symbol('a', real=True)\n",
      " |  >>> Interval(0, a)\n",
      " |  Interval(0, a)\n",
      " |  \n",
      " |  Notes\n",
      " |  =====\n",
      " |  - Only real end points are supported\n",
      " |  - ``Interval(a, b)`` with $a > b$ will return the empty set\n",
      " |  - Use the ``evalf()`` method to turn an Interval into an mpmath\n",
      " |    ``mpi`` interval instance\n",
      " |  \n",
      " |  References\n",
      " |  ==========\n",
      " |  \n",
      " |  .. [1] https://en.wikipedia.org/wiki/Interval_%28mathematics%29\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      Interval\n",
      " |      Set\n",
      " |      sympy.core.basic.Basic\n",
      " |      sympy.printing.defaults.Printable\n",
      " |      sympy.core.evalf.EvalfMixin\n",
      " |      builtins.object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  as_relational(self, x)\n",
      " |      Rewrite an interval in terms of inequalities and logic operators.\n",
      " |  \n",
      " |  to_mpi(self, prec=53)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods defined here:\n",
      " |  \n",
      " |  Lopen(a, b) from sympy.core.assumptions.ManagedProperties\n",
      " |      Return an interval not including the left boundary.\n",
      " |  \n",
      " |  Ropen(a, b) from sympy.core.assumptions.ManagedProperties\n",
      " |      Return an interval not including the right boundary.\n",
      " |  \n",
      " |  open(a, b) from sympy.core.assumptions.ManagedProperties\n",
      " |      Return an interval including neither boundary.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  __new__(cls, start, end, left_open=False, right_open=False)\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties defined here:\n",
      " |  \n",
      " |  __sympy__\n",
      " |  \n",
      " |  end\n",
      " |      The right end point of the interval.\n",
      " |      \n",
      " |      This property takes the same value as the ``sup`` property.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).end\n",
      " |      1\n",
      " |  \n",
      " |  is_empty\n",
      " |  \n",
      " |  is_finite_set\n",
      " |  \n",
      " |  is_left_unbounded\n",
      " |      Return ``True`` if the left endpoint is negative infinity.\n",
      " |  \n",
      " |  is_right_unbounded\n",
      " |      Return ``True`` if the right endpoint is positive infinity.\n",
      " |  \n",
      " |  left\n",
      " |  \n",
      " |  left_open\n",
      " |      True if interval is left-open.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1, left_open=True).left_open\n",
      " |      True\n",
      " |      >>> Interval(0, 1, left_open=False).left_open\n",
      " |      False\n",
      " |  \n",
      " |  right\n",
      " |  \n",
      " |  right_open\n",
      " |      True if interval is right-open.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1, right_open=True).right_open\n",
      " |      True\n",
      " |      >>> Interval(0, 1, right_open=False).right_open\n",
      " |      False\n",
      " |  \n",
      " |  start\n",
      " |      The left end point of the interval.\n",
      " |      \n",
      " |      This property takes the same value as the ``inf`` property.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).start\n",
      " |      0\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes defined here:\n",
      " |  \n",
      " |  default_assumptions = {}\n",
      " |  \n",
      " |  is_Interval = True\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from Set:\n",
      " |  \n",
      " |  __add__(self, other)\n",
      " |  \n",
      " |  __and__(self, other)\n",
      " |  \n",
      " |  __contains__(self, other)\n",
      " |  \n",
      " |  __mul__(self, other)\n",
      " |  \n",
      " |  __or__(self, other)\n",
      " |  \n",
      " |  __pow__(self, exp)\n",
      " |  \n",
      " |  __sub__(self, other)\n",
      " |  \n",
      " |  __xor__(self, other)\n",
      " |  \n",
      " |  complement(self, universe)\n",
      " |      The complement of 'self' w.r.t the given universe.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, S\n",
      " |      >>> Interval(0, 1).complement(S.Reals)\n",
      " |      Union(Interval.open(-oo, 0), Interval.open(1, oo))\n",
      " |      \n",
      " |      >>> Interval(0, 1).complement(S.UniversalSet)\n",
      " |      Complement(UniversalSet, Interval(0, 1))\n",
      " |  \n",
      " |  contains(self, other)\n",
      " |      Returns a SymPy value indicating whether ``other`` is contained\n",
      " |      in ``self``: ``true`` if it is, ``false`` if it isn't, else\n",
      " |      an unevaluated ``Contains`` expression (or, as in the case of\n",
      " |      ConditionSet and a union of FiniteSet/Intervals, an expression\n",
      " |      indicating the conditions for containment).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, S\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Interval(0, 1).contains(0.5)\n",
      " |      True\n",
      " |      \n",
      " |      As a shortcut it is possible to use the ``in`` operator, but that\n",
      " |      will raise an error unless an affirmative true or false is not\n",
      " |      obtained.\n",
      " |      \n",
      " |      >>> Interval(0, 1).contains(x)\n",
      " |      (0 <= x) & (x <= 1)\n",
      " |      >>> x in Interval(0, 1)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      TypeError: did not evaluate to a bool: None\n",
      " |      \n",
      " |      The result of 'in' is a bool, not a SymPy value\n",
      " |      \n",
      " |      >>> 1 in Interval(0, 2)\n",
      " |      True\n",
      " |      >>> _ is S.true\n",
      " |      False\n",
      " |  \n",
      " |  intersect(self, other)\n",
      " |      Returns the intersection of 'self' and 'other'.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      \n",
      " |      >>> Interval(1, 3).intersect(Interval(1, 2))\n",
      " |      Interval(1, 2)\n",
      " |      \n",
      " |      >>> from sympy import imageset, Lambda, symbols, S\n",
      " |      >>> n, m = symbols('n m')\n",
      " |      >>> a = imageset(Lambda(n, 2*n), S.Integers)\n",
      " |      >>> a.intersect(imageset(Lambda(m, 2*m + 1), S.Integers))\n",
      " |      EmptySet\n",
      " |  \n",
      " |  intersection(self, other)\n",
      " |      Alias for :meth:`intersect()`\n",
      " |  \n",
      " |  is_disjoint(self, other)\n",
      " |      Returns True if ``self`` and ``other`` are disjoint.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 2).is_disjoint(Interval(1, 2))\n",
      " |      False\n",
      " |      >>> Interval(0, 2).is_disjoint(Interval(3, 4))\n",
      " |      True\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Disjoint_sets\n",
      " |  \n",
      " |  is_proper_subset(self, other)\n",
      " |      Returns True if ``self`` is a proper subset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 0.5).is_proper_subset(Interval(0, 1))\n",
      " |      True\n",
      " |      >>> Interval(0, 1).is_proper_subset(Interval(0, 1))\n",
      " |      False\n",
      " |  \n",
      " |  is_proper_superset(self, other)\n",
      " |      Returns True if ``self`` is a proper superset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).is_proper_superset(Interval(0, 0.5))\n",
      " |      True\n",
      " |      >>> Interval(0, 1).is_proper_superset(Interval(0, 1))\n",
      " |      False\n",
      " |  \n",
      " |  is_subset(self, other)\n",
      " |      Returns True if ``self`` is a subset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 0.5).is_subset(Interval(0, 1))\n",
      " |      True\n",
      " |      >>> Interval(0, 1).is_subset(Interval(0, 1, left_open=True))\n",
      " |      False\n",
      " |  \n",
      " |  is_superset(self, other)\n",
      " |      Returns True if ``self`` is a superset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 0.5).is_superset(Interval(0, 1))\n",
      " |      False\n",
      " |      >>> Interval(0, 1).is_superset(Interval(0, 1, left_open=True))\n",
      " |      True\n",
      " |  \n",
      " |  isdisjoint(self, other)\n",
      " |      Alias for :meth:`is_disjoint()`\n",
      " |  \n",
      " |  issubset(self, other)\n",
      " |      Alias for :meth:`is_subset()`\n",
      " |  \n",
      " |  issuperset(self, other)\n",
      " |      Alias for :meth:`is_superset()`\n",
      " |  \n",
      " |  powerset(self)\n",
      " |      Find the Power set of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import EmptySet, FiniteSet, Interval\n",
      " |      \n",
      " |      A power set of an empty set:\n",
      " |      \n",
      " |      >>> A = EmptySet\n",
      " |      >>> A.powerset()\n",
      " |      {EmptySet}\n",
      " |      \n",
      " |      A power set of a finite set:\n",
      " |      \n",
      " |      >>> A = FiniteSet(1, 2)\n",
      " |      >>> a, b, c = FiniteSet(1), FiniteSet(2), FiniteSet(1, 2)\n",
      " |      >>> A.powerset() == FiniteSet(a, b, c, EmptySet)\n",
      " |      True\n",
      " |      \n",
      " |      A power set of an interval:\n",
      " |      \n",
      " |      >>> Interval(1, 2).powerset()\n",
      " |      PowerSet(Interval(1, 2))\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Power_set\n",
      " |  \n",
      " |  symmetric_difference(self, other)\n",
      " |      Returns symmetric difference of ``self`` and ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, S\n",
      " |      >>> Interval(1, 3).symmetric_difference(S.Reals)\n",
      " |      Union(Interval.open(-oo, 1), Interval.open(3, oo))\n",
      " |      >>> Interval(1, 10).symmetric_difference(S.Reals)\n",
      " |      Union(Interval.open(-oo, 1), Interval.open(10, oo))\n",
      " |      \n",
      " |      >>> from sympy import S, EmptySet\n",
      " |      >>> S.Reals.symmetric_difference(EmptySet)\n",
      " |      Reals\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      .. [1] https://en.wikipedia.org/wiki/Symmetric_difference\n",
      " |  \n",
      " |  union(self, other)\n",
      " |      Returns the union of ``self`` and ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      As a shortcut it is possible to use the ``+`` operator:\n",
      " |      \n",
      " |      >>> from sympy import Interval, FiniteSet\n",
      " |      >>> Interval(0, 1).union(Interval(2, 3))\n",
      " |      Union(Interval(0, 1), Interval(2, 3))\n",
      " |      >>> Interval(0, 1) + Interval(2, 3)\n",
      " |      Union(Interval(0, 1), Interval(2, 3))\n",
      " |      >>> Interval(1, 2, True, True) + FiniteSet(2, 3)\n",
      " |      Union({3}, Interval.Lopen(1, 2))\n",
      " |      \n",
      " |      Similarly it is possible to use the ``-`` operator for set differences:\n",
      " |      \n",
      " |      >>> Interval(0, 2) - Interval(0, 1)\n",
      " |      Interval.Lopen(1, 2)\n",
      " |      >>> Interval(1, 3) - FiniteSet(2)\n",
      " |      Union(Interval.Ropen(1, 2), Interval.Lopen(2, 3))\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from Set:\n",
      " |  \n",
      " |  boundary\n",
      " |      The boundary or frontier of a set.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A point x is on the boundary of a set S if\n",
      " |      \n",
      " |      1.  x is in the closure of S.\n",
      " |          I.e. Every neighborhood of x contains a point in S.\n",
      " |      2.  x is not in the interior of S.\n",
      " |          I.e. There does not exist an open set centered on x contained\n",
      " |          entirely within S.\n",
      " |      \n",
      " |      There are the points on the outer rim of S.  If S is open then these\n",
      " |      points need not actually be contained within S.\n",
      " |      \n",
      " |      For example, the boundary of an interval is its start and end points.\n",
      " |      This is true regardless of whether or not the interval is open.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).boundary\n",
      " |      {0, 1}\n",
      " |      >>> Interval(0, 1, True, False).boundary\n",
      " |      {0, 1}\n",
      " |  \n",
      " |  closure\n",
      " |      Property method which returns the closure of a set.\n",
      " |      The closure is defined as the union of the set itself and its\n",
      " |      boundary.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import S, Interval\n",
      " |      >>> S.Reals.closure\n",
      " |      Reals\n",
      " |      >>> Interval(0, 1).closure\n",
      " |      Interval(0, 1)\n",
      " |  \n",
      " |  inf\n",
      " |      The infimum of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, Union\n",
      " |      >>> Interval(0, 1).inf\n",
      " |      0\n",
      " |      >>> Union(Interval(0, 1), Interval(2, 3)).inf\n",
      " |      0\n",
      " |  \n",
      " |  interior\n",
      " |      Property method which returns the interior of a set.\n",
      " |      The interior of a set S consists all points of S that do not\n",
      " |      belong to the boundary of S.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).interior\n",
      " |      Interval.open(0, 1)\n",
      " |      >>> Interval(0, 1).boundary.interior\n",
      " |      EmptySet\n",
      " |  \n",
      " |  is_EmptySet\n",
      " |  \n",
      " |  is_closed\n",
      " |      A property method to check whether a set is closed.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A set is closed if its complement is an open set. The closedness of a\n",
      " |      subset of the reals is determined with respect to R and its standard\n",
      " |      topology.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).is_closed\n",
      " |      True\n",
      " |  \n",
      " |  is_open\n",
      " |      Property method to check whether a set is open.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A set is open if and only if it has an empty intersection with its\n",
      " |      boundary. In particular, a subset A of the reals is open if and only\n",
      " |      if each one of its points is contained in an open interval that is a\n",
      " |      subset of A.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import S\n",
      " |      >>> S.Reals.is_open\n",
      " |      True\n",
      " |      >>> S.Rationals.is_open\n",
      " |      False\n",
      " |  \n",
      " |  measure\n",
      " |      The (Lebesgue) measure of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, Union\n",
      " |      >>> Interval(0, 1).measure\n",
      " |      1\n",
      " |      >>> Union(Interval(0, 1), Interval(2, 3)).measure\n",
      " |      2\n",
      " |  \n",
      " |  sup\n",
      " |      The supremum of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, Union\n",
      " |      >>> Interval(0, 1).sup\n",
      " |      1\n",
      " |      >>> Union(Interval(0, 1), Interval(2, 3)).sup\n",
      " |      3\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from Set:\n",
      " |  \n",
      " |  __dict__\n",
      " |      dictionary for instance variables (if defined)\n",
      " |  \n",
      " |  __weakref__\n",
      " |      list of weak references to the object (if defined)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from Set:\n",
      " |  \n",
      " |  is_Complement = None\n",
      " |  \n",
      " |  is_ComplexRegion = False\n",
      " |  \n",
      " |  is_FiniteSet = False\n",
      " |  \n",
      " |  is_Intersection = None\n",
      " |  \n",
      " |  is_ProductSet = False\n",
      " |  \n",
      " |  is_Union = False\n",
      " |  \n",
      " |  is_UniversalSet = None\n",
      " |  \n",
      " |  is_interval = False\n",
      " |  \n",
      " |  is_iterable = False\n",
      " |  \n",
      " |  is_number = False\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __eq__(self, other)\n",
      " |      Return a boolean indicating whether a == b on the basis of\n",
      " |      their symbolic trees.\n",
      " |      \n",
      " |      This is the same as a.compare(b) == 0 but faster.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      If a class that overrides __eq__() needs to retain the\n",
      " |      implementation of __hash__() from a parent class, the\n",
      " |      interpreter must be told this explicitly by setting\n",
      " |      __hash__ : Callable[[object], int] = <ParentClass>.__hash__.\n",
      " |      Otherwise the inheritance of __hash__() will be blocked,\n",
      " |      just as if __hash__ had been explicitly set to None.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      from http://docs.python.org/dev/reference/datamodel.html#object.__hash__\n",
      " |  \n",
      " |  __getnewargs__(self)\n",
      " |  \n",
      " |  __getstate__(self)\n",
      " |  \n",
      " |  __hash__(self) -> int\n",
      " |      Return hash(self).\n",
      " |  \n",
      " |  __ne__(self, other)\n",
      " |      ``a != b``  -> Compare two symbolic trees and see whether they are different\n",
      " |      \n",
      " |      this is the same as:\n",
      " |      \n",
      " |      ``a.compare(b) != 0``\n",
      " |      \n",
      " |      but faster\n",
      " |  \n",
      " |  __reduce_ex__(self, protocol)\n",
      " |      Helper for pickle.\n",
      " |  \n",
      " |  __setstate__(self, state)\n",
      " |  \n",
      " |  as_content_primitive(self, radical=False, clear=True)\n",
      " |      A stub to allow Basic args (like Tuple) to be skipped when computing\n",
      " |      the content and primitive components of an expression.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.core.expr.Expr.as_content_primitive\n",
      " |  \n",
      " |  as_dummy(self)\n",
      " |      Return the expression with any objects having structurally\n",
      " |      bound symbols replaced with unique, canonical symbols within\n",
      " |      the object in which they appear and having only the default\n",
      " |      assumption for commutativity being True. When applied to a\n",
      " |      symbol a new symbol having only the same commutativity will be\n",
      " |      returned.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> r = Symbol('r', real=True)\n",
      " |      >>> Integral(r, (r, x)).as_dummy()\n",
      " |      Integral(_0, (_0, x))\n",
      " |      >>> _.variables[0].is_real is None\n",
      " |      True\n",
      " |      >>> r.as_dummy()\n",
      " |      _r\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Any object that has structurally bound variables should have\n",
      " |      a property, `bound_symbols` that returns those symbols\n",
      " |      appearing in the object.\n",
      " |  \n",
      " |  atoms(self, *types)\n",
      " |      Returns the atoms that form the current object.\n",
      " |      \n",
      " |      By default, only objects that are truly atomic and cannot\n",
      " |      be divided into smaller pieces are returned: symbols, numbers,\n",
      " |      and number symbols like I and pi. It is possible to request\n",
      " |      atoms of any type, however, as demonstrated below.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import I, pi, sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms()\n",
      " |      {1, 2, I, pi, x, y}\n",
      " |      \n",
      " |      If one or more types are given, the results will contain only\n",
      " |      those types of atoms.\n",
      " |      \n",
      " |      >>> from sympy import Number, NumberSymbol, Symbol\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Symbol)\n",
      " |      {x, y}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number)\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol)\n",
      " |      {1, 2, pi}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol, I)\n",
      " |      {1, 2, I, pi}\n",
      " |      \n",
      " |      Note that I (imaginary unit) and zoo (complex infinity) are special\n",
      " |      types of number symbols and are not part of the NumberSymbol class.\n",
      " |      \n",
      " |      The type can be given implicitly, too:\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(x) # x is a Symbol\n",
      " |      {x, y}\n",
      " |      \n",
      " |      Be careful to check your assumptions when using the implicit option\n",
      " |      since ``S(1).is_Integer = True`` but ``type(S(1))`` is ``One``, a special type\n",
      " |      of SymPy atom, while ``type(S(2))`` is type ``Integer`` and will find all\n",
      " |      integers in an expression:\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(1))\n",
      " |      {1}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(2))\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      Finally, arguments to atoms() can select more than atomic atoms: any\n",
      " |      SymPy type (loaded in core/__init__.py) can be listed as an argument\n",
      " |      and those types of \"atoms\" as found in scanning the arguments of the\n",
      " |      expression recursively:\n",
      " |      \n",
      " |      >>> from sympy import Function, Mul\n",
      " |      >>> from sympy.core.function import AppliedUndef\n",
      " |      >>> f = Function('f')\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(Function)\n",
      " |      {f(x), sin(y + I*pi)}\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(AppliedUndef)\n",
      " |      {f(x)}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Mul)\n",
      " |      {I*pi, 2*sin(y + I*pi)}\n",
      " |  \n",
      " |  compare(self, other)\n",
      " |      Return -1, 0, 1 if the object is smaller, equal, or greater than other.\n",
      " |      \n",
      " |      Not in the mathematical sense. If the object is of a different type\n",
      " |      from the \"other\" then their classes are ordered according to\n",
      " |      the sorted_classes list.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> x.compare(y)\n",
      " |      -1\n",
      " |      >>> x.compare(x)\n",
      " |      0\n",
      " |      >>> y.compare(x)\n",
      " |      1\n",
      " |  \n",
      " |  copy(self)\n",
      " |  \n",
      " |  could_extract_minus_sign(self)\n",
      " |  \n",
      " |  count(self, query)\n",
      " |      Count the number of matching subexpressions.\n",
      " |  \n",
      " |  count_ops(self, visual=None)\n",
      " |      wrapper for count_ops that returns the operation count.\n",
      " |  \n",
      " |  doit(self, **hints)\n",
      " |      Evaluate objects that are not evaluated by default like limits,\n",
      " |      integrals, sums and products. All objects of this kind will be\n",
      " |      evaluated recursively, unless some species were excluded via 'hints'\n",
      " |      or unless the 'deep' hint was set to 'False'.\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> 2*Integral(x, x)\n",
      " |      2*Integral(x, x)\n",
      " |      \n",
      " |      >>> (2*Integral(x, x)).doit()\n",
      " |      x**2\n",
      " |      \n",
      " |      >>> (2*Integral(x, x)).doit(deep=False)\n",
      " |      2*Integral(x, x)\n",
      " |  \n",
      " |  dummy_eq(self, other, symbol=None)\n",
      " |      Compare two expressions and handle dummy symbols.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Dummy\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> u = Dummy('u')\n",
      " |      \n",
      " |      >>> (u**2 + 1).dummy_eq(x**2 + 1)\n",
      " |      True\n",
      " |      >>> (u**2 + 1) == (x**2 + 1)\n",
      " |      False\n",
      " |      \n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, x)\n",
      " |      True\n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, y)\n",
      " |      False\n",
      " |  \n",
      " |  find(self, query, group=False)\n",
      " |      Find all subexpressions matching a query.\n",
      " |  \n",
      " |  has(self, *patterns)\n",
      " |      Test whether any subexpression matches any of the patterns.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x**2 + sin(x*y)).has(z)\n",
      " |      False\n",
      " |      >>> (x**2 + sin(x*y)).has(x, y, z)\n",
      " |      True\n",
      " |      >>> x.has(x)\n",
      " |      True\n",
      " |      \n",
      " |      Note ``has`` is a structural algorithm with no knowledge of\n",
      " |      mathematics. Consider the following half-open interval:\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> i = Interval.Lopen(0, 5); i\n",
      " |      Interval.Lopen(0, 5)\n",
      " |      >>> i.args\n",
      " |      (0, 5, True, False)\n",
      " |      >>> i.has(4)  # there is no \"4\" in the arguments\n",
      " |      False\n",
      " |      >>> i.has(0)  # there *is* a \"0\" in the arguments\n",
      " |      True\n",
      " |      \n",
      " |      Instead, use ``contains`` to determine whether a number is in the\n",
      " |      interval or not:\n",
      " |      \n",
      " |      >>> i.contains(4)\n",
      " |      True\n",
      " |      >>> i.contains(0)\n",
      " |      False\n",
      " |      \n",
      " |      \n",
      " |      Note that ``expr.has(*patterns)`` is exactly equivalent to\n",
      " |      ``any(expr.has(p) for p in patterns)``. In particular, ``False`` is\n",
      " |      returned when the list of patterns is empty.\n",
      " |      \n",
      " |      >>> x.has()\n",
      " |      False\n",
      " |  \n",
      " |  has_free(self, *patterns)\n",
      " |      return True if self has object(s) ``x`` as a free expression\n",
      " |      else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Function\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = Function('f')\n",
      " |      >>> g = Function('g')\n",
      " |      >>> expr = Integral(f(x), (f(x), 1, g(y)))\n",
      " |      >>> expr.free_symbols\n",
      " |      {y}\n",
      " |      >>> expr.has_free(g(y))\n",
      " |      True\n",
      " |      >>> expr.has_free(*(x, f(x)))\n",
      " |      False\n",
      " |      \n",
      " |      This works for subexpressions and types, too:\n",
      " |      \n",
      " |      >>> expr.has_free(g)\n",
      " |      True\n",
      " |      >>> (x + y + 1).has_free(y + 1)\n",
      " |      True\n",
      " |  \n",
      " |  is_hypergeometric(self, k)\n",
      " |  \n",
      " |  match(self, pattern, old=False)\n",
      " |      Pattern matching.\n",
      " |      \n",
      " |      Wild symbols match all.\n",
      " |      \n",
      " |      Return ``None`` when expression (self) does not match\n",
      " |      with pattern. Otherwise return a dictionary such that::\n",
      " |      \n",
      " |        pattern.xreplace(self.match(pattern)) == self\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Wild, Sum\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> p = Wild(\"p\")\n",
      " |      >>> q = Wild(\"q\")\n",
      " |      >>> r = Wild(\"r\")\n",
      " |      >>> e = (x+y)**(x+y)\n",
      " |      >>> e.match(p**p)\n",
      " |      {p_: x + y}\n",
      " |      >>> e.match(p**q)\n",
      " |      {p_: x + y, q_: x + y}\n",
      " |      >>> e = (2*x)**2\n",
      " |      >>> e.match(p*q**r)\n",
      " |      {p_: 4, q_: x, r_: 2}\n",
      " |      >>> (p*q**r).xreplace(e.match(p*q**r))\n",
      " |      4*x**2\n",
      " |      \n",
      " |      Structurally bound symbols are ignored during matching:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(y, (y, 1, p)))\n",
      " |      {p_: 2}\n",
      " |      \n",
      " |      But they can be identified if desired:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(q, (q, 1, p)))\n",
      " |      {p_: 2, q_: x}\n",
      " |      \n",
      " |      The ``old`` flag will give the old-style pattern matching where\n",
      " |      expressions and patterns are essentially solved to give the\n",
      " |      match. Both of the following give None unless ``old=True``:\n",
      " |      \n",
      " |      >>> (x - 2).match(p - x, old=True)\n",
      " |      {p_: 2*x - 2}\n",
      " |      >>> (2/x).match(p*x, old=True)\n",
      " |      {p_: 2/x**2}\n",
      " |  \n",
      " |  matches(self, expr, repl_dict=None, old=False)\n",
      " |      Helper method for match() that looks for a match between Wild symbols\n",
      " |      in self and expressions in expr.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, Wild, Basic\n",
      " |      >>> a, b, c = symbols('a b c')\n",
      " |      >>> x = Wild('x')\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b, c)) is None\n",
      " |      True\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b + c, b + c))\n",
      " |      {x_: b + c}\n",
      " |  \n",
      " |  rcall(self, *args)\n",
      " |      Apply on the argument recursively through the expression tree.\n",
      " |      \n",
      " |      This method is used to simulate a common abuse of notation for\n",
      " |      operators. For instance, in SymPy the following will not work:\n",
      " |      \n",
      " |      ``(x+Lambda(y, 2*y))(z) == x+2*z``,\n",
      " |      \n",
      " |      however, you can use:\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x + Lambda(y, 2*y)).rcall(z)\n",
      " |      x + 2*z\n",
      " |  \n",
      " |  refine(self, assumption=True)\n",
      " |      See the refine function in sympy.assumptions\n",
      " |  \n",
      " |  replace(self, query, value, map=False, simultaneous=True, exact=None)\n",
      " |      Replace matching subexpressions of ``self`` with ``value``.\n",
      " |      \n",
      " |      If ``map = True`` then also return the mapping {old: new} where ``old``\n",
      " |      was a sub-expression found with query and ``new`` is the replacement\n",
      " |      value for it. If the expression itself doesn't match the query, then\n",
      " |      the returned value will be ``self.xreplace(map)`` otherwise it should\n",
      " |      be ``self.subs(ordered(map.items()))``.\n",
      " |      \n",
      " |      Traverses an expression tree and performs replacement of matching\n",
      " |      subexpressions from the bottom to the top of the tree. The default\n",
      " |      approach is to do the replacement in a simultaneous fashion so\n",
      " |      changes made are targeted only once. If this is not desired or causes\n",
      " |      problems, ``simultaneous`` can be set to False.\n",
      " |      \n",
      " |      In addition, if an expression containing more than one Wild symbol\n",
      " |      is being used to match subexpressions and the ``exact`` flag is None\n",
      " |      it will be set to True so the match will only succeed if all non-zero\n",
      " |      values are received for each Wild that appears in the match pattern.\n",
      " |      Setting this to False accepts a match of 0; while setting it True\n",
      " |      accepts all matches that have a 0 in them. See example below for\n",
      " |      cautions.\n",
      " |      \n",
      " |      The list of possible combinations of queries and replacement values\n",
      " |      is listed below:\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      Initial setup\n",
      " |      \n",
      " |      >>> from sympy import log, sin, cos, tan, Wild, Mul, Add\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = log(sin(x)) + tan(sin(x**2))\n",
      " |      \n",
      " |      1.1. type -> type\n",
      " |          obj.replace(type, newtype)\n",
      " |      \n",
      " |          When object of type ``type`` is found, replace it with the\n",
      " |          result of passing its argument(s) to ``newtype``.\n",
      " |      \n",
      " |          >>> f.replace(sin, cos)\n",
      " |          log(cos(x)) + tan(cos(x**2))\n",
      " |          >>> sin(x).replace(sin, cos, map=True)\n",
      " |          (cos(x), {sin(x): cos(x)})\n",
      " |          >>> (x*y).replace(Mul, Add)\n",
      " |          x + y\n",
      " |      \n",
      " |      1.2. type -> func\n",
      " |          obj.replace(type, func)\n",
      " |      \n",
      " |          When object of type ``type`` is found, apply ``func`` to its\n",
      " |          argument(s). ``func`` must be written to handle the number\n",
      " |          of arguments of ``type``.\n",
      " |      \n",
      " |          >>> f.replace(sin, lambda arg: sin(2*arg))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |          >>> (x*y).replace(Mul, lambda *args: sin(2*Mul(*args)))\n",
      " |          sin(2*x*y)\n",
      " |      \n",
      " |      2.1. pattern -> expr\n",
      " |          obj.replace(pattern(wild), expr(wild))\n",
      " |      \n",
      " |          Replace subexpressions matching ``pattern`` with the expression\n",
      " |          written in terms of the Wild symbols in ``pattern``.\n",
      " |      \n",
      " |          >>> a, b = map(Wild, 'ab')\n",
      " |          >>> f.replace(sin(a), tan(a))\n",
      " |          log(tan(x)) + tan(tan(x**2))\n",
      " |          >>> f.replace(sin(a), tan(a/2))\n",
      " |          log(tan(x/2)) + tan(tan(x**2/2))\n",
      " |          >>> f.replace(sin(a), a)\n",
      " |          log(x) + tan(x**2)\n",
      " |          >>> (x*y).replace(a*x, a)\n",
      " |          y\n",
      " |      \n",
      " |          Matching is exact by default when more than one Wild symbol\n",
      " |          is used: matching fails unless the match gives non-zero\n",
      " |          values for all Wild symbols:\n",
      " |      \n",
      " |          >>> (2*x + y).replace(a*x + b, b - a)\n",
      " |          y - 2\n",
      " |          >>> (2*x).replace(a*x + b, b - a)\n",
      " |          2*x\n",
      " |      \n",
      " |          When set to False, the results may be non-intuitive:\n",
      " |      \n",
      " |          >>> (2*x).replace(a*x + b, b - a, exact=False)\n",
      " |          2/x\n",
      " |      \n",
      " |      2.2. pattern -> func\n",
      " |          obj.replace(pattern(wild), lambda wild: expr(wild))\n",
      " |      \n",
      " |          All behavior is the same as in 2.1 but now a function in terms of\n",
      " |          pattern variables is used rather than an expression:\n",
      " |      \n",
      " |          >>> f.replace(sin(a), lambda a: sin(2*a))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |      \n",
      " |      3.1. func -> func\n",
      " |          obj.replace(filter, func)\n",
      " |      \n",
      " |          Replace subexpression ``e`` with ``func(e)`` if ``filter(e)``\n",
      " |          is True.\n",
      " |      \n",
      " |          >>> g = 2*sin(x**3)\n",
      " |          >>> g.replace(lambda expr: expr.is_Number, lambda expr: expr**2)\n",
      " |          4*sin(x**9)\n",
      " |      \n",
      " |      The expression itself is also targeted by the query but is done in\n",
      " |      such a fashion that changes are not made twice.\n",
      " |      \n",
      " |          >>> e = x*(x*y + 1)\n",
      " |          >>> e.replace(lambda x: x.is_Mul, lambda x: 2*x)\n",
      " |          2*x*(2*x*y + 1)\n",
      " |      \n",
      " |      When matching a single symbol, `exact` will default to True, but\n",
      " |      this may or may not be the behavior that is desired:\n",
      " |      \n",
      " |      Here, we want `exact=False`:\n",
      " |      \n",
      " |      >>> from sympy import Function\n",
      " |      >>> f = Function('f')\n",
      " |      >>> e = f(1) + f(0)\n",
      " |      >>> q = f(a), lambda a: f(a + 1)\n",
      " |      >>> e.replace(*q, exact=False)\n",
      " |      f(1) + f(2)\n",
      " |      >>> e.replace(*q, exact=True)\n",
      " |      f(0) + f(2)\n",
      " |      \n",
      " |      But here, the nature of matching makes selecting\n",
      " |      the right setting tricky:\n",
      " |      \n",
      " |      >>> e = x**(1 + y)\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(-x - y + 1)\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(1 - y)\n",
      " |      \n",
      " |      It is probably better to use a different form of the query\n",
      " |      that describes the target expression more precisely:\n",
      " |      \n",
      " |      >>> (1 + x**(1 + y)).replace(\n",
      " |      ... lambda x: x.is_Pow and x.exp.is_Add and x.exp.args[0] == 1,\n",
      " |      ... lambda x: x.base**(1 - (x.exp - 1)))\n",
      " |      ...\n",
      " |      x**(1 - y) + 1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      subs: substitution of subexpressions as defined by the objects\n",
      " |            themselves.\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |  \n",
      " |  rewrite(self, *args, deep=True, **hints)\n",
      " |      Rewrite *self* using a defined rule.\n",
      " |      \n",
      " |      Rewriting transforms an expression to another, which is mathematically\n",
      " |      equivalent but structurally different. For example you can rewrite\n",
      " |      trigonometric functions as complex exponentials or combinatorial\n",
      " |      functions as gamma function.\n",
      " |      \n",
      " |      This method takes a *pattern* and a *rule* as positional arguments.\n",
      " |      *pattern* is optional parameter which defines the types of expressions\n",
      " |      that will be transformed. If it is not passed, all possible expressions\n",
      " |      will be rewritten. *rule* defines how the expression will be rewritten.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      args : *rule*, or *pattern* and *rule*.\n",
      " |          - *pattern* is a type or an iterable of types.\n",
      " |          - *rule* can be any object.\n",
      " |      \n",
      " |      deep : bool, optional.\n",
      " |          If ``True``, subexpressions are recursively transformed. Default is\n",
      " |          ``True``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      If *pattern* is unspecified, all possible expressions are transformed.\n",
      " |      \n",
      " |      >>> from sympy import cos, sin, exp, I\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> expr = cos(x) + I*sin(x)\n",
      " |      >>> expr.rewrite(exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Pattern can be a type or an iterable of types.\n",
      " |      \n",
      " |      >>> expr.rewrite(sin, exp)\n",
      " |      exp(I*x)/2 + cos(x) - exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos,], exp)\n",
      " |      exp(I*x)/2 + I*sin(x) + exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos, sin], exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Rewriting behavior can be implemented by defining ``_eval_rewrite()``\n",
      " |      method.\n",
      " |      \n",
      " |      >>> from sympy import Expr, sqrt, pi\n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite(self, rule, args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         if rule == cos:\n",
      " |      ...             return cos(pi/2 - x, evaluate=False)\n",
      " |      ...         if rule == sqrt:\n",
      " |      ...             return sqrt(1 - cos(x)**2)\n",
      " |      >>> MySin(MySin(x)).rewrite(cos)\n",
      " |      cos(-cos(-x + pi/2) + pi/2)\n",
      " |      >>> MySin(x).rewrite(sqrt)\n",
      " |      sqrt(1 - cos(x)**2)\n",
      " |      \n",
      " |      Defining ``_eval_rewrite_as_[...]()`` method is supported for backwards\n",
      " |      compatibility reason. This may be removed in the future and using it is\n",
      " |      discouraged.\n",
      " |      \n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite_as_cos(self, *args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         return cos(pi/2 - x, evaluate=False)\n",
      " |      >>> MySin(x).rewrite(cos)\n",
      " |      cos(-x + pi/2)\n",
      " |  \n",
      " |  simplify(self, **kwargs)\n",
      " |      See the simplify function in sympy.simplify\n",
      " |  \n",
      " |  sort_key(self, order=None)\n",
      " |      Return a sort key.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import S, I\n",
      " |      \n",
      " |      >>> sorted([S(1)/2, I, -I], key=lambda x: x.sort_key())\n",
      " |      [1/2, -I, I]\n",
      " |      \n",
      " |      >>> S(\"[x, 1/x, 1/x**2, x**2, x**(1/2), x**(1/4), x**(3/2)]\")\n",
      " |      [x, 1/x, x**(-2), x**2, sqrt(x), x**(1/4), x**(3/2)]\n",
      " |      >>> sorted(_, key=lambda x: x.sort_key())\n",
      " |      [x**(-2), 1/x, x**(1/4), sqrt(x), x, x**(3/2), x**2]\n",
      " |  \n",
      " |  subs(self, *args, **kwargs)\n",
      " |      Substitutes old for new in an expression after sympifying args.\n",
      " |      \n",
      " |      `args` is either:\n",
      " |        - two arguments, e.g. foo.subs(old, new)\n",
      " |        - one iterable argument, e.g. foo.subs(iterable). The iterable may be\n",
      " |           o an iterable container with (old, new) pairs. In this case the\n",
      " |             replacements are processed in the order given with successive\n",
      " |             patterns possibly affecting replacements already made.\n",
      " |           o a dict or set whose key/value items correspond to old/new pairs.\n",
      " |             In this case the old/new pairs will be sorted by op count and in\n",
      " |             case of a tie, by number of args and the default_sort_key. The\n",
      " |             resulting sorted list is then processed as an iterable container\n",
      " |             (see previous).\n",
      " |      \n",
      " |      If the keyword ``simultaneous`` is True, the subexpressions will not be\n",
      " |      evaluated until all the substitutions have been made.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import pi, exp, limit, oo\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x*y).subs(x, pi)\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).subs({x:pi, y:2})\n",
      " |      1 + 2*pi\n",
      " |      >>> (1 + x*y).subs([(x, pi), (y, 2)])\n",
      " |      1 + 2*pi\n",
      " |      >>> reps = [(y, x**2), (x, 2)]\n",
      " |      >>> (x + y).subs(reps)\n",
      " |      6\n",
      " |      >>> (x + y).subs(reversed(reps))\n",
      " |      x**2 + 2\n",
      " |      \n",
      " |      >>> (x**2 + x**4).subs(x**2, y)\n",
      " |      y**2 + y\n",
      " |      \n",
      " |      To replace only the x**2 but not the x**4, use xreplace:\n",
      " |      \n",
      " |      >>> (x**2 + x**4).xreplace({x**2: y})\n",
      " |      x**4 + y\n",
      " |      \n",
      " |      To delay evaluation until all substitutions have been made,\n",
      " |      set the keyword ``simultaneous`` to True:\n",
      " |      \n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)])\n",
      " |      0\n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)], simultaneous=True)\n",
      " |      nan\n",
      " |      \n",
      " |      This has the added feature of not allowing subsequent substitutions\n",
      " |      to affect those already made:\n",
      " |      \n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y})\n",
      " |      1\n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y}, simultaneous=True)\n",
      " |      y/(x + y)\n",
      " |      \n",
      " |      In order to obtain a canonical result, unordered iterables are\n",
      " |      sorted by count_op length, number of arguments and by the\n",
      " |      default_sort_key to break any ties. All other iterables are left\n",
      " |      unsorted.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, sin, cos\n",
      " |      >>> from sympy.abc import a, b, c, d, e\n",
      " |      \n",
      " |      >>> A = (sqrt(sin(2*x)), a)\n",
      " |      >>> B = (sin(2*x), b)\n",
      " |      >>> C = (cos(2*x), c)\n",
      " |      >>> D = (x, d)\n",
      " |      >>> E = (exp(x), e)\n",
      " |      \n",
      " |      >>> expr = sqrt(sin(2*x))*sin(exp(x)*x)*cos(2*x) + sin(2*x)\n",
      " |      \n",
      " |      >>> expr.subs(dict([A, B, C, D, E]))\n",
      " |      a*c*sin(d*e) + b\n",
      " |      \n",
      " |      The resulting expression represents a literal replacement of the\n",
      " |      old arguments with the new arguments. This may not reflect the\n",
      " |      limiting behavior of the expression:\n",
      " |      \n",
      " |      >>> (x**3 - 3*x).subs({x: oo})\n",
      " |      nan\n",
      " |      \n",
      " |      >>> limit(x**3 - 3*x, x, oo)\n",
      " |      oo\n",
      " |      \n",
      " |      If the substitution will be followed by numerical\n",
      " |      evaluation, it is better to pass the substitution to\n",
      " |      evalf as\n",
      " |      \n",
      " |      >>> (1/x).evalf(subs={x: 3.0}, n=21)\n",
      " |      0.333333333333333333333\n",
      " |      \n",
      " |      rather than\n",
      " |      \n",
      " |      >>> (1/x).subs({x: 3.0}).evalf(21)\n",
      " |      0.333333333333333314830\n",
      " |      \n",
      " |      as the former will ensure that the desired level of precision is\n",
      " |      obtained.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |      sympy.core.evalf.EvalfMixin.evalf: calculates the given formula to a desired level of precision\n",
      " |  \n",
      " |  xreplace(self, rule)\n",
      " |      Replace occurrences of objects within the expression.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      rule : dict-like\n",
      " |          Expresses a replacement rule\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      xreplace : the result of the replacement\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, pi, exp\n",
      " |      >>> x, y, z = symbols('x y z')\n",
      " |      >>> (1 + x*y).xreplace({x: pi})\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).xreplace({x: pi, y: 2})\n",
      " |      1 + 2*pi\n",
      " |      \n",
      " |      Replacements occur only if an entire node in the expression tree is\n",
      " |      matched:\n",
      " |      \n",
      " |      >>> (x*y + z).xreplace({x*y: pi})\n",
      " |      z + pi\n",
      " |      >>> (x*y*z).xreplace({x*y: pi})\n",
      " |      x*y*z\n",
      " |      >>> (2*x).xreplace({2*x: y, x: z})\n",
      " |      y\n",
      " |      >>> (2*2*x).xreplace({2*x: y, x: z})\n",
      " |      4*z\n",
      " |      >>> (x + y + 2).xreplace({x + y: 2})\n",
      " |      x + y + 2\n",
      " |      >>> (x + 2 + exp(x + 2)).xreplace({x + 2: y})\n",
      " |      x + exp(y) + 2\n",
      " |      \n",
      " |      xreplace doesn't differentiate between free and bound symbols. In the\n",
      " |      following, subs(x, y) would not change x since it is a bound symbol,\n",
      " |      but xreplace does:\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> Integral(x, (x, 1, 2*x)).xreplace({x: y})\n",
      " |      Integral(y, (y, 1, 2*y))\n",
      " |      \n",
      " |      Trying to replace x with an expression raises an error:\n",
      " |      \n",
      " |      >>> Integral(x, (x, 1, 2*x)).xreplace({x: 2*y}) # doctest: +SKIP\n",
      " |      ValueError: Invalid limits given: ((2*y, 1, 4*y),)\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      subs: substitution of subexpressions as defined by the objects\n",
      " |            themselves.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  class_key() from sympy.core.assumptions.ManagedProperties\n",
      " |      Nice order of classes.\n",
      " |  \n",
      " |  fromiter(args, **assumptions) from sympy.core.assumptions.ManagedProperties\n",
      " |      Create a new object from an iterable.\n",
      " |      \n",
      " |      This is a convenience function that allows one to create objects from\n",
      " |      any iterable, without having to convert to a list or tuple first.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Tuple\n",
      " |      >>> Tuple.fromiter(i for i in range(5))\n",
      " |      (0, 1, 2, 3, 4)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  args\n",
      " |      Returns a tuple of arguments of 'self'.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cot\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> cot(x).args\n",
      " |      (x,)\n",
      " |      \n",
      " |      >>> cot(x).args[0]\n",
      " |      x\n",
      " |      \n",
      " |      >>> (x*y).args\n",
      " |      (x, y)\n",
      " |      \n",
      " |      >>> (x*y).args[1]\n",
      " |      y\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Never use self._args, always use self.args.\n",
      " |      Only use _args in __new__ when creating a new function.\n",
      " |      Don't override .args() from Basic (so that it's easy to\n",
      " |      change the interface in the future if needed).\n",
      " |  \n",
      " |  assumptions0\n",
      " |      Return object `type` assumptions.\n",
      " |      \n",
      " |      For example:\n",
      " |      \n",
      " |        Symbol('x', real=True)\n",
      " |        Symbol('x', integer=True)\n",
      " |      \n",
      " |      are different objects. In other words, besides Python type (Symbol in\n",
      " |      this case), the initial assumptions are also forming their typeinfo.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True}\n",
      " |      >>> x = Symbol(\"x\", positive=True)\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True, 'complex': True, 'extended_negative': False,\n",
      " |       'extended_nonnegative': True, 'extended_nonpositive': False,\n",
      " |       'extended_nonzero': True, 'extended_positive': True, 'extended_real':\n",
      " |       True, 'finite': True, 'hermitian': True, 'imaginary': False,\n",
      " |       'infinite': False, 'negative': False, 'nonnegative': True,\n",
      " |       'nonpositive': False, 'nonzero': True, 'positive': True, 'real':\n",
      " |       True, 'zero': False}\n",
      " |  \n",
      " |  canonical_variables\n",
      " |      Return a dictionary mapping any variable defined in\n",
      " |      ``self.bound_symbols`` to Symbols that do not clash\n",
      " |      with any free symbols in the expression.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> Lambda(x, 2*x).canonical_variables\n",
      " |      {x: _0}\n",
      " |  \n",
      " |  expr_free_symbols\n",
      " |  \n",
      " |  free_symbols\n",
      " |      Return from the atoms of self those which are free symbols.\n",
      " |      \n",
      " |      For most expressions, all symbols are free symbols. For some classes\n",
      " |      this is not true. e.g. Integrals use Symbols for the dummy variables\n",
      " |      which are bound variables, so Integral has a method to return all\n",
      " |      symbols except those. Derivative keeps track of symbols with respect\n",
      " |      to which it will perform a derivative; those are\n",
      " |      bound variables, too, so it has its own free_symbols method.\n",
      " |      \n",
      " |      Any other method that uses bound variables should implement a\n",
      " |      free_symbols method.\n",
      " |  \n",
      " |  func\n",
      " |      The top-level function in an expression.\n",
      " |      \n",
      " |      The following should hold for all objects::\n",
      " |      \n",
      " |          >> x == x.func(*x.args)\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> a = 2*x\n",
      " |      >>> a.func\n",
      " |      <class 'sympy.core.mul.Mul'>\n",
      " |      >>> a.args\n",
      " |      (2, x)\n",
      " |      >>> a.func(*a.args)\n",
      " |      2*x\n",
      " |      >>> a == a.func(*a.args)\n",
      " |      True\n",
      " |  \n",
      " |  is_algebraic\n",
      " |  \n",
      " |  is_antihermitian\n",
      " |  \n",
      " |  is_commutative\n",
      " |  \n",
      " |  is_comparable\n",
      " |      Return True if self can be computed to a real number\n",
      " |      (or already is a real number) with precision, else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import exp_polar, pi, I\n",
      " |      >>> (I*exp_polar(I*pi/2)).is_comparable\n",
      " |      True\n",
      " |      >>> (I*exp_polar(I*pi*2)).is_comparable\n",
      " |      False\n",
      " |      \n",
      " |      A False result does not mean that `self` cannot be rewritten\n",
      " |      into a form that would be comparable. For example, the\n",
      " |      difference computed below is zero but without simplification\n",
      " |      it does not evaluate to a zero with precision:\n",
      " |      \n",
      " |      >>> e = 2**pi*(1 + 2**pi)\n",
      " |      >>> dif = e - e.expand()\n",
      " |      >>> dif.is_comparable\n",
      " |      False\n",
      " |      >>> dif.n(2)._prec\n",
      " |      1\n",
      " |  \n",
      " |  is_complex\n",
      " |  \n",
      " |  is_composite\n",
      " |  \n",
      " |  is_even\n",
      " |  \n",
      " |  is_extended_negative\n",
      " |  \n",
      " |  is_extended_nonnegative\n",
      " |  \n",
      " |  is_extended_nonpositive\n",
      " |  \n",
      " |  is_extended_nonzero\n",
      " |  \n",
      " |  is_extended_positive\n",
      " |  \n",
      " |  is_extended_real\n",
      " |  \n",
      " |  is_finite\n",
      " |  \n",
      " |  is_hermitian\n",
      " |  \n",
      " |  is_imaginary\n",
      " |  \n",
      " |  is_infinite\n",
      " |  \n",
      " |  is_integer\n",
      " |  \n",
      " |  is_irrational\n",
      " |  \n",
      " |  is_negative\n",
      " |  \n",
      " |  is_noninteger\n",
      " |  \n",
      " |  is_nonnegative\n",
      " |  \n",
      " |  is_nonpositive\n",
      " |  \n",
      " |  is_nonzero\n",
      " |  \n",
      " |  is_odd\n",
      " |  \n",
      " |  is_polar\n",
      " |  \n",
      " |  is_positive\n",
      " |  \n",
      " |  is_prime\n",
      " |  \n",
      " |  is_rational\n",
      " |  \n",
      " |  is_real\n",
      " |  \n",
      " |  is_transcendental\n",
      " |  \n",
      " |  is_zero\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __annotations__ = {'_args': 'Tuple[Basic, ...]', '_mhash': 'Any', 'kin...\n",
      " |  \n",
      " |  is_Add = False\n",
      " |  \n",
      " |  is_AlgebraicNumber = False\n",
      " |  \n",
      " |  is_Atom = False\n",
      " |  \n",
      " |  is_Boolean = False\n",
      " |  \n",
      " |  is_Derivative = False\n",
      " |  \n",
      " |  is_Dummy = False\n",
      " |  \n",
      " |  is_Equality = False\n",
      " |  \n",
      " |  is_Float = False\n",
      " |  \n",
      " |  is_Function = False\n",
      " |  \n",
      " |  is_Indexed = False\n",
      " |  \n",
      " |  is_Integer = False\n",
      " |  \n",
      " |  is_MatAdd = False\n",
      " |  \n",
      " |  is_MatMul = False\n",
      " |  \n",
      " |  is_Matrix = False\n",
      " |  \n",
      " |  is_Mul = False\n",
      " |  \n",
      " |  is_Not = False\n",
      " |  \n",
      " |  is_Number = False\n",
      " |  \n",
      " |  is_NumberSymbol = False\n",
      " |  \n",
      " |  is_Order = False\n",
      " |  \n",
      " |  is_Piecewise = False\n",
      " |  \n",
      " |  is_Point = False\n",
      " |  \n",
      " |  is_Poly = False\n",
      " |  \n",
      " |  is_Pow = False\n",
      " |  \n",
      " |  is_Rational = False\n",
      " |  \n",
      " |  is_Relational = False\n",
      " |  \n",
      " |  is_Symbol = False\n",
      " |  \n",
      " |  is_Vector = False\n",
      " |  \n",
      " |  is_Wild = False\n",
      " |  \n",
      " |  is_symbol = False\n",
      " |  \n",
      " |  kind = UndefinedKind\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.printing.defaults.Printable:\n",
      " |  \n",
      " |  __repr__ = __str__(self)\n",
      " |  \n",
      " |  __str__(self)\n",
      " |      Return str(self).\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.evalf.EvalfMixin:\n",
      " |  \n",
      " |  evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      " |      Evaluate the given formula to an accuracy of *n* digits.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      subs : dict, optional\n",
      " |          Substitute numerical values for symbols, e.g.\n",
      " |          ``subs={x:3, y:1+pi}``. The substitutions must be given as a\n",
      " |          dictionary.\n",
      " |      \n",
      " |      maxn : int, optional\n",
      " |          Allow a maximum temporary working precision of maxn digits.\n",
      " |      \n",
      " |      chop : bool or number, optional\n",
      " |          Specifies how to replace tiny real or imaginary parts in\n",
      " |          subresults by exact zeros.\n",
      " |      \n",
      " |          When ``True`` the chop value defaults to standard precision.\n",
      " |      \n",
      " |          Otherwise the chop value is used to determine the\n",
      " |          magnitude of \"small\" for purposes of chopping.\n",
      " |      \n",
      " |          >>> from sympy import N\n",
      " |          >>> x = 1e-4\n",
      " |          >>> N(x, chop=True)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-5)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-4)\n",
      " |          0\n",
      " |      \n",
      " |      strict : bool, optional\n",
      " |          Raise ``PrecisionExhausted`` if any subresult fails to\n",
      " |          evaluate to full accuracy, given the available maxprec.\n",
      " |      \n",
      " |      quad : str, optional\n",
      " |          Choose algorithm for numerical quadrature. By default,\n",
      " |          tanh-sinh quadrature is used. For oscillatory\n",
      " |          integrals on an infinite interval, try ``quad='osc'``.\n",
      " |      \n",
      " |      verbose : bool, optional\n",
      " |          Print debug information.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      When Floats are naively substituted into an expression,\n",
      " |      precision errors may adversely affect the result. For example,\n",
      " |      adding 1e16 (a Float) to 1 will truncate to 1e16; if 1e16 is\n",
      " |      then subtracted, the result will be 0.\n",
      " |      That is exactly what happens in the following:\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> values = {x: 1e16, y: 1, z: 1e16}\n",
      " |      >>> (x + y - z).subs(values)\n",
      " |      0\n",
      " |      \n",
      " |      Using the subs argument for evalf is the accurate way to\n",
      " |      evaluate such an expression:\n",
      " |      \n",
      " |      >>> (x + y - z).evalf(subs=values)\n",
      " |      1.00000000000000\n",
      " |  \n",
      " |  n = evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(Interval)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "f98e49ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.calculus.util import continuous_domain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 213,
   "id": "77e50776",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=log(3-4*x+x**2,10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 215,
   "id": "01fbe74b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left(-\\infty, 1\\right) \\cup \\left(3, \\infty\\right)$"
      ],
      "text/plain": [
       "Union(Interval.open(-oo, 1), Interval.open(3, oo))"
      ]
     },
     "execution_count": 215,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "continuous_domain(expr,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 216,
   "id": "71856ad0",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'Union' object has no attribute 'left_open'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Input \u001b[0;32mIn [216]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mfunction_monotonyset\u001b[49m\u001b[43m(\u001b[49m\u001b[43mexpr\u001b[49m\u001b[43m,\u001b[49m\u001b[43mx\u001b[49m\u001b[43m,\u001b[49m\u001b[43mcontinuous_domain\u001b[49m\u001b[43m(\u001b[49m\u001b[43mexpr\u001b[49m\u001b[43m,\u001b[49m\u001b[43mx\u001b[49m\u001b[43m,\u001b[49m\u001b[43mReals\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/Documents/packaging_tutorial/src/function_calculator_package/extreme_points.py:25\u001b[0m, in \u001b[0;36mfunction_monotonyset\u001b[0;34m(f, x, interval, dir)\u001b[0m\n\u001b[1;32m     11\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m     12\u001b[0m \u001b[38;5;124;03m    there is a question: who can we judge\u001b[39;00m\n\u001b[1;32m     13\u001b[0m \u001b[38;5;124;03m    the function on one interval is increasing\u001b[39;00m\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m     22\u001b[0m \u001b[38;5;124;03m    we can also compare the two function values.\u001b[39;00m\n\u001b[1;32m     23\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m     24\u001b[0m \u001b[38;5;66;03m# we should first check the interval's edge.\u001b[39;00m\n\u001b[0;32m---> 25\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m(\u001b[43minterval\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mleft_open\u001b[49m):\n\u001b[1;32m     26\u001b[0m     interval_inf_value\u001b[38;5;241m=\u001b[39mlimit(f,x,interval\u001b[38;5;241m.\u001b[39minf,\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m+\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m     27\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
      "\u001b[0;31mAttributeError\u001b[0m: 'Union' object has no attribute 'left_open'"
     ]
    }
   ],
   "source": [
    "function_monotonyset(expr,x,continuous_domain(expr,x,Reals))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "d01b529e",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=log(4*x+8,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1bbd9f17",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left(-2, - \\frac{3}{2}\\right)$"
      ],
      "text/plain": [
       "Interval.open(-2, -3/2)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(expr<1,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e04f1aa0",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{n}{2} + \\frac{1}{2}$"
      ],
      "text/plain": [
       "n/2 + 1/2"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rsolve(2*f(n+1)-2*f(n)-1,f(n),{f(8):Rational(9,2)})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "e427126f",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 2$"
      ],
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rsolve(2*f(n+1)-2*f(n)-1,f(n),{f(8):Rational(9,2)}).subs(n,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "dd70148d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{y^{2}}{b^{2}} + \\frac{x^{2}}{a^{2}} = 1$"
      ],
      "text/plain": [
       "Eq(y**2/b**2 + x**2/a**2, 1)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eq=Eq(x**2/a**2+y**2/b**2,1)\n",
    "eq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "9695f11b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{\\left(a + \\frac{\\sqrt{3} x}{3}\\right)^{2}}{b^{2}} + \\frac{x^{2}}{a^{2}} = 1$"
      ],
      "text/plain": [
       "Eq((a + sqrt(3)*x/3)**2/b**2 + x**2/a**2, 1)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eq.subs(y,x/sqrt(3)+a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "c9441740",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=(eq.subs(y,x/sqrt(3)+a).lhs-eq.subs(y,x/sqrt(3)+a).rhs)*a**2*b**2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "7a0e374e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle a^{4} + \\frac{2 \\sqrt{3} a^{3} x}{3} - a^{2} b^{2} + \\frac{a^{2} x^{2}}{3} + b^{2} x^{2}$"
      ],
      "text/plain": [
       "a**4 + 2*sqrt(3)*a**3*x/3 - a**2*b**2 + a**2*x**2/3 + b**2*x**2"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand(expr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "b8e32fa2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 0.693147180559945$"
      ],
      "text/plain": [
       "0.693147180559945"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(ln(2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "389e2a4c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 1.09861228866811$"
      ],
      "text/plain": [
       "1.09861228866811"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(ln(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "1f1b4bd4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 0.14384103622589$"
      ],
      "text/plain": [
       "0.143841036225890"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N((ln(4)-ln(3))/2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "9bcf9914",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5500.0"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "0.693/0.000126"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "5593a502",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 18.0617997398389$"
      ],
      "text/plain": [
       "18.0617997398389"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(60*log(2,10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "e03b88bb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 0.976211544005309$"
      ],
      "text/plain": [
       "0.976211544005309"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(Rational(1,2))**(1/28.79)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "3709e0fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.4998298026124483"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r=0.0238\n",
    "(1-r)**28.79"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "289c003a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle -0.0104611966794976$"
      ],
      "text/plain": [
       "-0.0104611966794976"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(log(0.9762,10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "9ea100c6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.915201033864482e-06"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(1/2)**(500/28.79)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "0a4feb38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{\\left(\\frac{3 x}{2} + 1\\right)^{10}}{\\left(x + 1\\right)^{10}}$"
      ],
      "text/plain": [
       "(3*x/2 + 1)**10/(x + 1)**10"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=((1+Rational(3,2)*x)/(1+x))**10\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "cad1c307",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'+': Interval.open(0, oo), '-': []}"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_monotonyset(expr,x,Interval.open(0,oo))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "8b50c9ef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[3/2 - sqrt(5)/2, sqrt(5)/2 + 3/2]"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer=list(solveset(x+1/x-3,x))\n",
    "answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "cee5742b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{True}$"
      ],
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Eq(sqrt(answer[1])+1/sqrt(answer[1]),sqrt(5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "89c29550",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{True}$"
      ],
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Eq(sqrt(answer[0])+1/sqrt(answer[0]),sqrt(5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "3f9304c3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle a$"
      ],
      "text/plain": [
       "a"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "f4c22a59",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 9 a + 525$"
      ],
      "text/plain": [
       "9*a + 525"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "summation(a+(2*n-1)*n,(n,1,9))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "11dcc8f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{2 \\cdot 3^{m} m - 3^{m} + 1}{2}$"
      ],
      "text/plain": [
       "(2*3**m*m - 3**m + 1)/2"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "summation(2*n*3**(n-1),(n,1,m))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "601721d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "24559"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3*2**13-17"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "b1a10e0b",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function function_range in module sympy.calculus.util:\n",
      "\n",
      "function_range(f, symbol, domain)\n",
      "    Finds the range of a function in a given domain.\n",
      "    This method is limited by the ability to determine the singularities and\n",
      "    determine limits.\n",
      "    \n",
      "    Parameters\n",
      "    ==========\n",
      "    \n",
      "    f : :py:class:`~.Expr`\n",
      "        The concerned function.\n",
      "    symbol : :py:class:`~.Symbol`\n",
      "        The variable for which the range of function is to be determined.\n",
      "    domain : :py:class:`~.Interval`\n",
      "        The domain under which the range of the function has to be found.\n",
      "    \n",
      "    Examples\n",
      "    ========\n",
      "    \n",
      "    >>> from sympy import Interval, Symbol, S, exp, log, pi, sqrt, sin, tan\n",
      "    >>> from sympy.calculus.util import function_range\n",
      "    >>> x = Symbol('x')\n",
      "    >>> function_range(sin(x), x, Interval(0, 2*pi))\n",
      "    Interval(-1, 1)\n",
      "    >>> function_range(tan(x), x, Interval(-pi/2, pi/2))\n",
      "    Interval(-oo, oo)\n",
      "    >>> function_range(1/x, x, S.Reals)\n",
      "    Union(Interval.open(-oo, 0), Interval.open(0, oo))\n",
      "    >>> function_range(exp(x), x, S.Reals)\n",
      "    Interval.open(0, oo)\n",
      "    >>> function_range(log(x), x, S.Reals)\n",
      "    Interval(-oo, oo)\n",
      "    >>> function_range(sqrt(x), x, Interval(-5, 9))\n",
      "    Interval(0, 3)\n",
      "    \n",
      "    Returns\n",
      "    =======\n",
      "    \n",
      "    :py:class:`~.Interval`\n",
      "        Union of all ranges for all intervals under domain where function is\n",
      "        continuous.\n",
      "    \n",
      "    Raises\n",
      "    ======\n",
      "    \n",
      "    NotImplementedError\n",
      "        If any of the intervals, in the given domain, for which function\n",
      "        is continuous are not finite or real,\n",
      "        OR if the critical points of the function on the domain cannot be found.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(function_range)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "54d8e934",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{x^{2} - x + 4}{x + 3}$"
      ],
      "text/plain": [
       "(x**2 - x + 4)/(x + 3)"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=((y+2)/(x+3)).subs(y,x**2-x+2)\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "a86f65d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[1, 3\\right]$"
      ],
      "text/plain": [
       "Interval(1, 3)"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_range(expr,x,Interval.Ropen(-1,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "48125fd1",
   "metadata": {},
   "outputs": [],
   "source": [
    "A=Point(1,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "2aa73865",
   "metadata": {},
   "outputs": [],
   "source": [
    "B=Point(5,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "1dced2a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "C=Point(-3,-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "da74a41d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 2 x + 4 y - 14$"
      ],
      "text/plain": [
       "2*x + 4*y - 14"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Line(A,B).equation()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "a9a49d8c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - 2 x + 8 y + 2$"
      ],
      "text/plain": [
       "-2*x + 8*y + 2"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Line(C,B).equation()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "7984e0cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 4 x - 4 y + 8$"
      ],
      "text/plain": [
       "4*x - 4*y + 8"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Line(A,C).equation()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "7722e6ef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{9 \\sqrt{13}}{13}$"
      ],
      "text/plain": [
       "9*sqrt(13)/13"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(36/sqrt(208))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "03812a5e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{x^{2}}{16} - \\frac{y^{2}}{8} - 1$"
      ],
      "text/plain": [
       "x**2/16 - y**2/8 - 1"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=x**2/16-y**2/8-1\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "2bb90c69",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - 2 k^{2} x^{2} + 8 \\sqrt{6} k^{2} x - 48 k^{2} + x^{2} - 16$"
      ],
      "text/plain": [
       "-2*k**2*x**2 + 8*sqrt(6)*k**2*x - 48*k**2 + x**2 - 16"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand(expr.subs(y,k*(x-2*sqrt(6))))*16"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "ab22246c",
   "metadata": {},
   "outputs": [],
   "source": [
    "answer=list(solveset(expand(expr.subs(y,k*(x-2*sqrt(6))))*16,x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "5025bddb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 8 \\sqrt{\\frac{k^{2} + 1}{4 k^{4} - 4 k^{2} + 1}}$"
      ],
      "text/plain": [
       "8*sqrt((k**2 + 1)/(4*k**4 - 4*k**2 + 1))"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sqrt(simplify(sum(answer)**2-4*answer[0]*answer[1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "f47f8b0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle t$"
      ],
      "text/plain": [
       "t"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "f57b798c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{\\left( -2, \\  0\\right), \\left( \\frac{2 \\left(- t + \\frac{54 t}{t^{2} + 27}\\right)}{t}, \\  \\frac{18 t}{t^{2} + 27}\\right)\\right\\}$"
      ],
      "text/plain": [
       "{(-2, 0), (2*(-t + 54*t/(t**2 + 27))/t, 18*t/(t**2 + 27))}"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nonlinsolve([Eq(y,t/6*(x+2)),Eq(x**2/4+y**2/3,1)],[x,y])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "0d82e596",
   "metadata": {},
   "outputs": [],
   "source": [
    "answer=list(nonlinsolve([Eq(y,t/6*(x+2)),Eq(x**2/4+y**2/3,1)],[x,y]))[1][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "894e2b9b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{2 \\cdot \\left(27 - t^{2}\\right)}{t^{2} + 27}$"
      ],
      "text/plain": [
       "2*(27 - t**2)/(t**2 + 27)"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "a946679d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle y = \\frac{18 t}{t^{2} + 27}$"
      ],
      "text/plain": [
       "Eq(y, 18*t/(t**2 + 27))"
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(Eq(y,t/6*(x+2)).subs(x,simplify(answer)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1e997017",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "id": "6fb9c5ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{2 \\left(t^{2} - 3\\right)}{t^{2} + 3}$"
      ],
      "text/plain": [
       "2*(t**2 - 3)/(t**2 + 3)"
      ]
     },
     "execution_count": 127,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(list(nonlinsolve([Eq(y,t/2*(x-2)),Eq(x**2/4+y**2/3,1)],[x,y]))[1][0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "id": "95e76681",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=(18*t/(27+t**2)+6*t/(3+t**2))/((54-2*t**2)/(27+t**2)-(2*t**2-6)/(3+t**2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "id": "577bd861",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\frac{6 t}{t^{2} - 9}$"
      ],
      "text/plain": [
       "-6*t/(t**2 - 9)"
      ]
     },
     "execution_count": 131,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(expr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8fcb9747",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "id": "7b82b34e",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_x=[140,150,170,180,195]\n",
    "data_y=[23,24,26,28,28]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "d65b82cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.stats import moment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "id": "5fc6959d",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function FiniteRV in module sympy.stats.frv_types:\n",
      "\n",
      "FiniteRV(name, density, **kwargs)\n",
      "    Create a Finite Random Variable given a dict representing the density.\n",
      "    \n",
      "    Parameters\n",
      "    ==========\n",
      "    \n",
      "    name : Symbol\n",
      "        Represents name of the random variable.\n",
      "    density: A dict\n",
      "        Dictionary conatining the pdf of finite distribution\n",
      "    check : bool\n",
      "        If True, it will check whether the given density\n",
      "        integrates to 1 over the given set. If False, it\n",
      "        will not perform this check. Default is False.\n",
      "    \n",
      "    Examples\n",
      "    ========\n",
      "    \n",
      "    >>> from sympy.stats import FiniteRV, P, E\n",
      "    \n",
      "    >>> density = {0: .1, 1: .2, 2: .3, 3: .4}\n",
      "    >>> X = FiniteRV('X', density)\n",
      "    \n",
      "    >>> E(X)\n",
      "    2.00000000000000\n",
      "    >>> P(X >= 2)\n",
      "    0.700000000000000\n",
      "    \n",
      "    Returns\n",
      "    =======\n",
      "    \n",
      "    RandomSymbol\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(FiniteRV)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "id": "40e0f982",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function moment in module sympy.stats.rv_interface:\n",
      "\n",
      "moment(X, n, c=0, condition=None, *, evaluate=True, **kwargs)\n",
      "    Return the nth moment of a random expression about c.\n",
      "    \n",
      "    .. math::\n",
      "        moment(X, c, n) = E((X-c)^{n})\n",
      "    \n",
      "    Default value of c is 0.\n",
      "    \n",
      "    Examples\n",
      "    ========\n",
      "    \n",
      "    >>> from sympy.stats import Die, moment, E\n",
      "    >>> X = Die('X', 6)\n",
      "    >>> moment(X, 1, 6)\n",
      "    -5/2\n",
      "    >>> moment(X, 2)\n",
      "    91/6\n",
      "    >>> moment(X, 1) == E(X)\n",
      "    True\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(moment)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "b6b47deb",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class MutableDenseMatrix in module sympy.matrices.dense:\n",
      "\n",
      "class MutableDenseMatrix(DenseMatrix, sympy.matrices.repmatrix.MutableRepMatrix)\n",
      " |  MutableDenseMatrix(*args, **kwargs)\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      MutableDenseMatrix\n",
      " |      DenseMatrix\n",
      " |      sympy.matrices.repmatrix.MutableRepMatrix\n",
      " |      sympy.matrices.repmatrix.RepMatrix\n",
      " |      sympy.matrices.matrices.MatrixBase\n",
      " |      sympy.matrices.matrices.MatrixDeprecated\n",
      " |      sympy.matrices.matrices.MatrixCalculus\n",
      " |      sympy.matrices.matrices.MatrixEigen\n",
      " |      sympy.matrices.matrices.MatrixSubspaces\n",
      " |      sympy.matrices.matrices.MatrixReductions\n",
      " |      sympy.matrices.matrices.MatrixDeterminant\n",
      " |      sympy.matrices.common.MatrixCommon\n",
      " |      sympy.matrices.common.MatrixArithmetic\n",
      " |      sympy.matrices.common.MatrixOperations\n",
      " |      sympy.matrices.common.MatrixProperties\n",
      " |      sympy.matrices.common.MatrixSpecial\n",
      " |      sympy.matrices.common.MatrixShaping\n",
      " |      sympy.matrices.common.MatrixRequired\n",
      " |      sympy.printing.defaults.Printable\n",
      " |      builtins.object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  simplify(self, **kwargs)\n",
      " |      Applies simplify to the elements of a matrix in place.\n",
      " |      \n",
      " |      This is a shortcut for M.applyfunc(lambda x: simplify(x, ratio, measure))\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.simplify.simplify.simplify\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from DenseMatrix:\n",
      " |  \n",
      " |  LDLdecomposition(self, hermitian=True)\n",
      " |      Returns the LDL Decomposition (L, D) of matrix A,\n",
      " |      such that L * D * L.H == A if hermitian flag is True, or\n",
      " |      L * D * L.T == A if hermitian is False.\n",
      " |      This method eliminates the use of square root.\n",
      " |      Further this ensures that all the diagonal entries of L are 1.\n",
      " |      A must be a Hermitian positive-definite matrix if hermitian is True,\n",
      " |      or a symmetric matrix otherwise.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, eye\n",
      " |      >>> A = Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))\n",
      " |      >>> L, D = A.LDLdecomposition()\n",
      " |      >>> L\n",
      " |      Matrix([\n",
      " |      [   1,   0, 0],\n",
      " |      [ 3/5,   1, 0],\n",
      " |      [-1/5, 1/3, 1]])\n",
      " |      >>> D\n",
      " |      Matrix([\n",
      " |      [25, 0, 0],\n",
      " |      [ 0, 9, 0],\n",
      " |      [ 0, 0, 9]])\n",
      " |      >>> L * D * L.T * A.inv() == eye(A.rows)\n",
      " |      True\n",
      " |      \n",
      " |      The matrix can have complex entries:\n",
      " |      \n",
      " |      >>> from sympy import I\n",
      " |      >>> A = Matrix(((9, 3*I), (-3*I, 5)))\n",
      " |      >>> L, D = A.LDLdecomposition()\n",
      " |      >>> L\n",
      " |      Matrix([\n",
      " |      [   1, 0],\n",
      " |      [-I/3, 1]])\n",
      " |      >>> D\n",
      " |      Matrix([\n",
      " |      [9, 0],\n",
      " |      [0, 4]])\n",
      " |      >>> L*D*L.H == A\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.cholesky\n",
      " |      sympy.matrices.matrices.MatrixBase.LUdecomposition\n",
      " |      QRdecomposition\n",
      " |  \n",
      " |  as_immutable(self)\n",
      " |      Returns an Immutable version of this Matrix\n",
      " |  \n",
      " |  as_mutable(self)\n",
      " |      Returns a mutable version of this matrix\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import ImmutableMatrix\n",
      " |      >>> X = ImmutableMatrix([[1, 2], [3, 4]])\n",
      " |      >>> Y = X.as_mutable()\n",
      " |      >>> Y[1, 1] = 5 # Can set values in Y\n",
      " |      >>> Y\n",
      " |      Matrix([\n",
      " |      [1, 2],\n",
      " |      [3, 5]])\n",
      " |  \n",
      " |  cholesky(self, hermitian=True)\n",
      " |      Returns the Cholesky-type decomposition L of a matrix A\n",
      " |      such that L * L.H == A if hermitian flag is True,\n",
      " |      or L * L.T == A if hermitian is False.\n",
      " |      \n",
      " |      A must be a Hermitian positive-definite matrix if hermitian is True,\n",
      " |      or a symmetric matrix if it is False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))\n",
      " |      >>> A.cholesky()\n",
      " |      Matrix([\n",
      " |      [ 5, 0, 0],\n",
      " |      [ 3, 3, 0],\n",
      " |      [-1, 1, 3]])\n",
      " |      >>> A.cholesky() * A.cholesky().T\n",
      " |      Matrix([\n",
      " |      [25, 15, -5],\n",
      " |      [15, 18,  0],\n",
      " |      [-5,  0, 11]])\n",
      " |      \n",
      " |      The matrix can have complex entries:\n",
      " |      \n",
      " |      >>> from sympy import I\n",
      " |      >>> A = Matrix(((9, 3*I), (-3*I, 5)))\n",
      " |      >>> A.cholesky()\n",
      " |      Matrix([\n",
      " |      [ 3, 0],\n",
      " |      [-I, 2]])\n",
      " |      >>> A.cholesky() * A.cholesky().H\n",
      " |      Matrix([\n",
      " |      [   9, 3*I],\n",
      " |      [-3*I,   5]])\n",
      " |      \n",
      " |      Non-hermitian Cholesky-type decomposition may be useful when the\n",
      " |      matrix is not positive-definite.\n",
      " |      \n",
      " |      >>> A = Matrix([[1, 2], [2, 1]])\n",
      " |      >>> L = A.cholesky(hermitian=False)\n",
      " |      >>> L\n",
      " |      Matrix([\n",
      " |      [1,         0],\n",
      " |      [2, sqrt(3)*I]])\n",
      " |      >>> L*L.T == A\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.LDLdecomposition\n",
      " |      sympy.matrices.matrices.MatrixBase.LUdecomposition\n",
      " |      QRdecomposition\n",
      " |  \n",
      " |  lower_triangular_solve(self, rhs)\n",
      " |      Solves ``Ax = B``, where A is a lower triangular matrix.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      upper_triangular_solve\n",
      " |      gauss_jordan_solve\n",
      " |      cholesky_solve\n",
      " |      diagonal_solve\n",
      " |      LDLsolve\n",
      " |      LUsolve\n",
      " |      QRsolve\n",
      " |      pinv_solve\n",
      " |  \n",
      " |  upper_triangular_solve(self, rhs)\n",
      " |      Solves ``Ax = B``, where A is an upper triangular matrix.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      lower_triangular_solve\n",
      " |      gauss_jordan_solve\n",
      " |      cholesky_solve\n",
      " |      diagonal_solve\n",
      " |      LDLsolve\n",
      " |      LUsolve\n",
      " |      QRsolve\n",
      " |      pinv_solve\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from DenseMatrix:\n",
      " |  \n",
      " |  is_MatrixExpr = False\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.repmatrix.MutableRepMatrix:\n",
      " |  \n",
      " |  __setitem__(self, key, value)\n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, I, zeros, ones\n",
      " |      >>> m = Matrix(((1, 2+I), (3, 4)))\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 2 + I],\n",
      " |      [3,     4]])\n",
      " |      >>> m[1, 0] = 9\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 2 + I],\n",
      " |      [9,     4]])\n",
      " |      >>> m[1, 0] = [[0, 1]]\n",
      " |      \n",
      " |      To replace row r you assign to position r*m where m\n",
      " |      is the number of columns:\n",
      " |      \n",
      " |      >>> M = zeros(4)\n",
      " |      >>> m = M.cols\n",
      " |      >>> M[3*m] = ones(1, m)*2; M\n",
      " |      Matrix([\n",
      " |      [0, 0, 0, 0],\n",
      " |      [0, 0, 0, 0],\n",
      " |      [0, 0, 0, 0],\n",
      " |      [2, 2, 2, 2]])\n",
      " |      \n",
      " |      And to replace column c you can assign to position c:\n",
      " |      \n",
      " |      >>> M[2] = ones(m, 1)*4; M\n",
      " |      Matrix([\n",
      " |      [0, 0, 4, 0],\n",
      " |      [0, 0, 4, 0],\n",
      " |      [0, 0, 4, 0],\n",
      " |      [2, 2, 4, 2]])\n",
      " |  \n",
      " |  col_op(self, j, f)\n",
      " |      In-place operation on col j using two-arg functor whose args are\n",
      " |      interpreted as (self[i, j], i).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import eye\n",
      " |      >>> M = eye(3)\n",
      " |      >>> M.col_op(1, lambda v, i: v + 2*M[i, 0]); M\n",
      " |      Matrix([\n",
      " |      [1, 2, 0],\n",
      " |      [0, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      col\n",
      " |      row_op\n",
      " |  \n",
      " |  col_swap(self, i, j)\n",
      " |      Swap the two given columns of the matrix in-place.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 0], [1, 0]])\n",
      " |      >>> M\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [1, 0]])\n",
      " |      >>> M.col_swap(0, 1)\n",
      " |      >>> M\n",
      " |      Matrix([\n",
      " |      [0, 1],\n",
      " |      [0, 1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      col\n",
      " |      row_swap\n",
      " |  \n",
      " |  copy(self)\n",
      " |      Returns the copy of a matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix(2, 2, [1, 2, 3, 4])\n",
      " |      >>> A.copy()\n",
      " |      Matrix([\n",
      " |      [1, 2],\n",
      " |      [3, 4]])\n",
      " |  \n",
      " |  copyin_list(self, key, value)\n",
      " |      Copy in elements from a list.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      key : slice\n",
      " |          The section of this matrix to replace.\n",
      " |      value : iterable\n",
      " |          The iterable to copy values from.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import eye\n",
      " |      >>> I = eye(3)\n",
      " |      >>> I[:2, 0] = [1, 2] # col\n",
      " |      >>> I\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [2, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      >>> I[1, :2] = [[3, 4]]\n",
      " |      >>> I\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [3, 4, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      copyin_matrix\n",
      " |  \n",
      " |  copyin_matrix(self, key, value)\n",
      " |      Copy in values from a matrix into the given bounds.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      key : slice\n",
      " |          The section of this matrix to replace.\n",
      " |      value : Matrix\n",
      " |          The matrix to copy values from.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, eye\n",
      " |      >>> M = Matrix([[0, 1], [2, 3], [4, 5]])\n",
      " |      >>> I = eye(3)\n",
      " |      >>> I[:3, :2] = M\n",
      " |      >>> I\n",
      " |      Matrix([\n",
      " |      [0, 1, 0],\n",
      " |      [2, 3, 0],\n",
      " |      [4, 5, 1]])\n",
      " |      >>> I[0, 1] = M\n",
      " |      >>> I\n",
      " |      Matrix([\n",
      " |      [0, 0, 1],\n",
      " |      [2, 2, 3],\n",
      " |      [4, 4, 5]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      copyin_list\n",
      " |  \n",
      " |  fill(self, value)\n",
      " |      Fill self with the given value.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Unless many values are going to be deleted (i.e. set to zero)\n",
      " |      this will create a matrix that is slower than a dense matrix in\n",
      " |      operations.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import SparseMatrix\n",
      " |      >>> M = SparseMatrix.zeros(3); M\n",
      " |      Matrix([\n",
      " |      [0, 0, 0],\n",
      " |      [0, 0, 0],\n",
      " |      [0, 0, 0]])\n",
      " |      >>> M.fill(1); M\n",
      " |      Matrix([\n",
      " |      [1, 1, 1],\n",
      " |      [1, 1, 1],\n",
      " |      [1, 1, 1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      zeros\n",
      " |      ones\n",
      " |  \n",
      " |  row_op(self, i, f)\n",
      " |      In-place operation on row ``i`` using two-arg functor whose args are\n",
      " |      interpreted as ``(self[i, j], j)``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import eye\n",
      " |      >>> M = eye(3)\n",
      " |      >>> M.row_op(1, lambda v, j: v + 2*M[0, j]); M\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [2, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      row\n",
      " |      zip_row_op\n",
      " |      col_op\n",
      " |  \n",
      " |  row_swap(self, i, j)\n",
      " |      Swap the two given rows of the matrix in-place.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[0, 1], [1, 0]])\n",
      " |      >>> M\n",
      " |      Matrix([\n",
      " |      [0, 1],\n",
      " |      [1, 0]])\n",
      " |      >>> M.row_swap(0, 1)\n",
      " |      >>> M\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      row\n",
      " |      col_swap\n",
      " |  \n",
      " |  zip_row_op(self, i, k, f)\n",
      " |      In-place operation on row ``i`` using two-arg functor whose args are\n",
      " |      interpreted as ``(self[i, j], self[k, j])``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import eye\n",
      " |      >>> M = eye(3)\n",
      " |      >>> M.zip_row_op(1, 0, lambda v, u: v + 2*u); M\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [2, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      row\n",
      " |      row_op\n",
      " |      col_op\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods inherited from sympy.matrices.repmatrix.MutableRepMatrix:\n",
      " |  \n",
      " |  __new__(cls, *args, **kwargs)\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.matrices.repmatrix.MutableRepMatrix:\n",
      " |  \n",
      " |  is_zero = False\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.repmatrix.RepMatrix:\n",
      " |  \n",
      " |  __eq__(self, other)\n",
      " |      Return self==value.\n",
      " |  \n",
      " |  __getitem__(self, key)\n",
      " |      Implementations of __getitem__ should accept ints, in which\n",
      " |      case the matrix is indexed as a flat list, tuples (i,j) in which\n",
      " |      case the (i,j) entry is returned, slices, or mixed tuples (a,b)\n",
      " |      where a and b are any combination of slices and integers.\n",
      " |  \n",
      " |  equals(self, other, failing_expression=False)\n",
      " |      Applies ``equals`` to corresponding elements of the matrices,\n",
      " |      trying to prove that the elements are equivalent, returning True\n",
      " |      if they are, False if any pair is not, and None (or the first\n",
      " |      failing expression if failing_expression is True) if it cannot\n",
      " |      be decided if the expressions are equivalent or not. This is, in\n",
      " |      general, an expensive operation.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> A = Matrix([x*(x - 1), 0])\n",
      " |      >>> B = Matrix([x**2 - x, 0])\n",
      " |      >>> A == B\n",
      " |      False\n",
      " |      >>> A.simplify() == B.simplify()\n",
      " |      True\n",
      " |      >>> A.equals(B)\n",
      " |      True\n",
      " |      >>> A.equals(2)\n",
      " |      False\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      sympy.core.expr.Expr.equals\n",
      " |  \n",
      " |  flat(self)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.matrices.repmatrix.RepMatrix:\n",
      " |  \n",
      " |  kind\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.matrices.repmatrix.RepMatrix:\n",
      " |  \n",
      " |  __annotations__ = {'_rep': <class 'sympy.polys.matrices.domainmatrix.D...\n",
      " |  \n",
      " |  __hash__ = None\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.matrices.MatrixBase:\n",
      " |  \n",
      " |  LDLsolve(self, rhs)\n",
      " |      Solves ``Ax = B`` using LDL decomposition,\n",
      " |      for a general square and non-singular matrix.\n",
      " |      \n",
      " |      For a non-square matrix with rows > cols,\n",
      " |      the least squares solution is returned.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, eye\n",
      " |      >>> A = eye(2)*2\n",
      " |      >>> B = Matrix([[1, 2], [3, 4]])\n",
      " |      >>> A.LDLsolve(B) == B/2\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.LDLdecomposition\n",
      " |      sympy.matrices.dense.DenseMatrix.lower_triangular_solve\n",
      " |      sympy.matrices.dense.DenseMatrix.upper_triangular_solve\n",
      " |      gauss_jordan_solve\n",
      " |      cholesky_solve\n",
      " |      diagonal_solve\n",
      " |      LUsolve\n",
      " |      QRsolve\n",
      " |      pinv_solve\n",
      " |  \n",
      " |  LUdecomposition(self, iszerofunc=<function _iszero at 0x7f27787b60d0>, simpfunc=None, rankcheck=False)\n",
      " |      Returns (L, U, perm) where L is a lower triangular matrix with unit\n",
      " |      diagonal, U is an upper triangular matrix, and perm is a list of row\n",
      " |      swap index pairs. If A is the original matrix, then\n",
      " |      ``A = (L*U).permuteBkwd(perm)``, and the row permutation matrix P such\n",
      " |      that $P A = L U$ can be computed by ``P = eye(A.rows).permuteFwd(perm)``.\n",
      " |      \n",
      " |      See documentation for LUCombined for details about the keyword argument\n",
      " |      rankcheck, iszerofunc, and simpfunc.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      rankcheck : bool, optional\n",
      " |          Determines if this function should detect the rank\n",
      " |          deficiency of the matrixis and should raise a\n",
      " |          ``ValueError``.\n",
      " |      \n",
      " |      iszerofunc : function, optional\n",
      " |          A function which determines if a given expression is zero.\n",
      " |      \n",
      " |          The function should be a callable that takes a single\n",
      " |          SymPy expression and returns a 3-valued boolean value\n",
      " |          ``True``, ``False``, or ``None``.\n",
      " |      \n",
      " |          It is internally used by the pivot searching algorithm.\n",
      " |          See the notes section for a more information about the\n",
      " |          pivot searching algorithm.\n",
      " |      \n",
      " |      simpfunc : function or None, optional\n",
      " |          A function that simplifies the input.\n",
      " |      \n",
      " |          If this is specified as a function, this function should be\n",
      " |          a callable that takes a single SymPy expression and returns\n",
      " |          an another SymPy expression that is algebraically\n",
      " |          equivalent.\n",
      " |      \n",
      " |          If ``None``, it indicates that the pivot search algorithm\n",
      " |          should not attempt to simplify any candidate pivots.\n",
      " |      \n",
      " |          It is internally used by the pivot searching algorithm.\n",
      " |          See the notes section for a more information about the\n",
      " |          pivot searching algorithm.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> a = Matrix([[4, 3], [6, 3]])\n",
      " |      >>> L, U, _ = a.LUdecomposition()\n",
      " |      >>> L\n",
      " |      Matrix([\n",
      " |      [  1, 0],\n",
      " |      [3/2, 1]])\n",
      " |      >>> U\n",
      " |      Matrix([\n",
      " |      [4,    3],\n",
      " |      [0, -3/2]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.cholesky\n",
      " |      sympy.matrices.dense.DenseMatrix.LDLdecomposition\n",
      " |      QRdecomposition\n",
      " |      LUdecomposition_Simple\n",
      " |      LUdecompositionFF\n",
      " |      LUsolve\n",
      " |  \n",
      " |  LUdecompositionFF(self)\n",
      " |      Compute a fraction-free LU decomposition.\n",
      " |      \n",
      " |      Returns 4 matrices P, L, D, U such that PA = L D**-1 U.\n",
      " |      If the elements of the matrix belong to some integral domain I, then all\n",
      " |      elements of L, D and U are guaranteed to belong to I.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.matrices.MatrixBase.LUdecomposition\n",
      " |      LUdecomposition_Simple\n",
      " |      LUsolve\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] W. Zhou & D.J. Jeffrey, \"Fraction-free matrix factors: new forms\n",
      " |          for LU and QR factors\". Frontiers in Computer Science in China,\n",
      " |          Vol 2, no. 1, pp. 67-80, 2008.\n",
      " |  \n",
      " |  LUdecomposition_Simple(self, iszerofunc=<function _iszero at 0x7f27787b60d0>, simpfunc=None, rankcheck=False)\n",
      " |      Compute the PLU decomposition of the matrix.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      rankcheck : bool, optional\n",
      " |          Determines if this function should detect the rank\n",
      " |          deficiency of the matrixis and should raise a\n",
      " |          ``ValueError``.\n",
      " |      \n",
      " |      iszerofunc : function, optional\n",
      " |          A function which determines if a given expression is zero.\n",
      " |      \n",
      " |          The function should be a callable that takes a single\n",
      " |          SymPy expression and returns a 3-valued boolean value\n",
      " |          ``True``, ``False``, or ``None``.\n",
      " |      \n",
      " |          It is internally used by the pivot searching algorithm.\n",
      " |          See the notes section for a more information about the\n",
      " |          pivot searching algorithm.\n",
      " |      \n",
      " |      simpfunc : function or None, optional\n",
      " |          A function that simplifies the input.\n",
      " |      \n",
      " |          If this is specified as a function, this function should be\n",
      " |          a callable that takes a single SymPy expression and returns\n",
      " |          an another SymPy expression that is algebraically\n",
      " |          equivalent.\n",
      " |      \n",
      " |          If ``None``, it indicates that the pivot search algorithm\n",
      " |          should not attempt to simplify any candidate pivots.\n",
      " |      \n",
      " |          It is internally used by the pivot searching algorithm.\n",
      " |          See the notes section for a more information about the\n",
      " |          pivot searching algorithm.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      (lu, row_swaps) : (Matrix, list)\n",
      " |          If the original matrix is a $m, n$ matrix:\n",
      " |      \n",
      " |          *lu* is a $m, n$ matrix, which contains result of the\n",
      " |          decomposition in a compresed form. See the notes section\n",
      " |          to see how the matrix is compressed.\n",
      " |      \n",
      " |          *row_swaps* is a $m$-element list where each element is a\n",
      " |          pair of row exchange indices.\n",
      " |      \n",
      " |          ``A = (L*U).permute_backward(perm)``, and the row\n",
      " |          permutation matrix $P$ from the formula $P A = L U$ can be\n",
      " |          computed by ``P=eye(A.row).permute_forward(perm)``.\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      ValueError\n",
      " |          Raised if ``rankcheck=True`` and the matrix is found to\n",
      " |          be rank deficient during the computation.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      About the PLU decomposition:\n",
      " |      \n",
      " |      PLU decomposition is a generalization of a LU decomposition\n",
      " |      which can be extended for rank-deficient matrices.\n",
      " |      \n",
      " |      It can further be generalized for non-square matrices, and this\n",
      " |      is the notation that SymPy is using.\n",
      " |      \n",
      " |      PLU decomposition is a decomposition of a $m, n$ matrix $A$ in\n",
      " |      the form of $P A = L U$ where\n",
      " |      \n",
      " |      * $L$ is a $m, m$ lower triangular matrix with unit diagonal\n",
      " |          entries.\n",
      " |      * $U$ is a $m, n$ upper triangular matrix.\n",
      " |      * $P$ is a $m, m$ permutation matrix.\n",
      " |      \n",
      " |      So, for a square matrix, the decomposition would look like:\n",
      " |      \n",
      " |      .. math::\n",
      " |          L = \\begin{bmatrix}\n",
      " |          1 & 0 & 0 & \\cdots & 0 \\\\\n",
      " |          L_{1, 0} & 1 & 0 & \\cdots & 0 \\\\\n",
      " |          L_{2, 0} & L_{2, 1} & 1 & \\cdots & 0 \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
      " |          L_{n-1, 0} & L_{n-1, 1} & L_{n-1, 2} & \\cdots & 1\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      .. math::\n",
      " |          U = \\begin{bmatrix}\n",
      " |          U_{0, 0} & U_{0, 1} & U_{0, 2} & \\cdots & U_{0, n-1} \\\\\n",
      " |          0 & U_{1, 1} & U_{1, 2} & \\cdots & U_{1, n-1} \\\\\n",
      " |          0 & 0 & U_{2, 2} & \\cdots & U_{2, n-1} \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
      " |          0 & 0 & 0 & \\cdots & U_{n-1, n-1}\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      And for a matrix with more rows than the columns,\n",
      " |      the decomposition would look like:\n",
      " |      \n",
      " |      .. math::\n",
      " |          L = \\begin{bmatrix}\n",
      " |          1 & 0 & 0 & \\cdots & 0 & 0 & \\cdots & 0 \\\\\n",
      " |          L_{1, 0} & 1 & 0 & \\cdots & 0 & 0 & \\cdots & 0 \\\\\n",
      " |          L_{2, 0} & L_{2, 1} & 1 & \\cdots & 0 & 0 & \\cdots & 0 \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots & \\ddots\n",
      " |          & \\vdots \\\\\n",
      " |          L_{n-1, 0} & L_{n-1, 1} & L_{n-1, 2} & \\cdots & 1 & 0\n",
      " |          & \\cdots & 0 \\\\\n",
      " |          L_{n, 0} & L_{n, 1} & L_{n, 2} & \\cdots & L_{n, n-1} & 1\n",
      " |          & \\cdots & 0 \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots & \\vdots\n",
      " |          & \\ddots & \\vdots \\\\\n",
      " |          L_{m-1, 0} & L_{m-1, 1} & L_{m-1, 2} & \\cdots & L_{m-1, n-1}\n",
      " |          & 0 & \\cdots & 1 \\\\\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      .. math::\n",
      " |          U = \\begin{bmatrix}\n",
      " |          U_{0, 0} & U_{0, 1} & U_{0, 2} & \\cdots & U_{0, n-1} \\\\\n",
      " |          0 & U_{1, 1} & U_{1, 2} & \\cdots & U_{1, n-1} \\\\\n",
      " |          0 & 0 & U_{2, 2} & \\cdots & U_{2, n-1} \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
      " |          0 & 0 & 0 & \\cdots & U_{n-1, n-1} \\\\\n",
      " |          0 & 0 & 0 & \\cdots & 0 \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
      " |          0 & 0 & 0 & \\cdots & 0\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      Finally, for a matrix with more columns than the rows, the\n",
      " |      decomposition would look like:\n",
      " |      \n",
      " |      .. math::\n",
      " |          L = \\begin{bmatrix}\n",
      " |          1 & 0 & 0 & \\cdots & 0 \\\\\n",
      " |          L_{1, 0} & 1 & 0 & \\cdots & 0 \\\\\n",
      " |          L_{2, 0} & L_{2, 1} & 1 & \\cdots & 0 \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
      " |          L_{m-1, 0} & L_{m-1, 1} & L_{m-1, 2} & \\cdots & 1\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      .. math::\n",
      " |          U = \\begin{bmatrix}\n",
      " |          U_{0, 0} & U_{0, 1} & U_{0, 2} & \\cdots & U_{0, m-1}\n",
      " |          & \\cdots & U_{0, n-1} \\\\\n",
      " |          0 & U_{1, 1} & U_{1, 2} & \\cdots & U_{1, m-1}\n",
      " |          & \\cdots & U_{1, n-1} \\\\\n",
      " |          0 & 0 & U_{2, 2} & \\cdots & U_{2, m-1}\n",
      " |          & \\cdots & U_{2, n-1} \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\n",
      " |          & \\cdots & \\vdots \\\\\n",
      " |          0 & 0 & 0 & \\cdots & U_{m-1, m-1}\n",
      " |          & \\cdots & U_{m-1, n-1} \\\\\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      About the compressed LU storage:\n",
      " |      \n",
      " |      The results of the decomposition are often stored in compressed\n",
      " |      forms rather than returning $L$ and $U$ matrices individually.\n",
      " |      \n",
      " |      It may be less intiuitive, but it is commonly used for a lot of\n",
      " |      numeric libraries because of the efficiency.\n",
      " |      \n",
      " |      The storage matrix is defined as following for this specific\n",
      " |      method:\n",
      " |      \n",
      " |      * The subdiagonal elements of $L$ are stored in the subdiagonal\n",
      " |          portion of $LU$, that is $LU_{i, j} = L_{i, j}$ whenever\n",
      " |          $i > j$.\n",
      " |      * The elements on the diagonal of $L$ are all 1, and are not\n",
      " |          explicitly stored.\n",
      " |      * $U$ is stored in the upper triangular portion of $LU$, that is\n",
      " |          $LU_{i, j} = U_{i, j}$ whenever $i <= j$.\n",
      " |      * For a case of $m > n$, the right side of the $L$ matrix is\n",
      " |          trivial to store.\n",
      " |      * For a case of $m < n$, the below side of the $U$ matrix is\n",
      " |          trivial to store.\n",
      " |      \n",
      " |      So, for a square matrix, the compressed output matrix would be:\n",
      " |      \n",
      " |      .. math::\n",
      " |          LU = \\begin{bmatrix}\n",
      " |          U_{0, 0} & U_{0, 1} & U_{0, 2} & \\cdots & U_{0, n-1} \\\\\n",
      " |          L_{1, 0} & U_{1, 1} & U_{1, 2} & \\cdots & U_{1, n-1} \\\\\n",
      " |          L_{2, 0} & L_{2, 1} & U_{2, 2} & \\cdots & U_{2, n-1} \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
      " |          L_{n-1, 0} & L_{n-1, 1} & L_{n-1, 2} & \\cdots & U_{n-1, n-1}\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      For a matrix with more rows than the columns, the compressed\n",
      " |      output matrix would be:\n",
      " |      \n",
      " |      .. math::\n",
      " |          LU = \\begin{bmatrix}\n",
      " |          U_{0, 0} & U_{0, 1} & U_{0, 2} & \\cdots & U_{0, n-1} \\\\\n",
      " |          L_{1, 0} & U_{1, 1} & U_{1, 2} & \\cdots & U_{1, n-1} \\\\\n",
      " |          L_{2, 0} & L_{2, 1} & U_{2, 2} & \\cdots & U_{2, n-1} \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
      " |          L_{n-1, 0} & L_{n-1, 1} & L_{n-1, 2} & \\cdots\n",
      " |          & U_{n-1, n-1} \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
      " |          L_{m-1, 0} & L_{m-1, 1} & L_{m-1, 2} & \\cdots\n",
      " |          & L_{m-1, n-1} \\\\\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      For a matrix with more columns than the rows, the compressed\n",
      " |      output matrix would be:\n",
      " |      \n",
      " |      .. math::\n",
      " |          LU = \\begin{bmatrix}\n",
      " |          U_{0, 0} & U_{0, 1} & U_{0, 2} & \\cdots & U_{0, m-1}\n",
      " |          & \\cdots & U_{0, n-1} \\\\\n",
      " |          L_{1, 0} & U_{1, 1} & U_{1, 2} & \\cdots & U_{1, m-1}\n",
      " |          & \\cdots & U_{1, n-1} \\\\\n",
      " |          L_{2, 0} & L_{2, 1} & U_{2, 2} & \\cdots & U_{2, m-1}\n",
      " |          & \\cdots & U_{2, n-1} \\\\\n",
      " |          \\vdots & \\vdots & \\vdots & \\ddots & \\vdots\n",
      " |          & \\cdots & \\vdots \\\\\n",
      " |          L_{m-1, 0} & L_{m-1, 1} & L_{m-1, 2} & \\cdots & U_{m-1, m-1}\n",
      " |          & \\cdots & U_{m-1, n-1} \\\\\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      About the pivot searching algorithm:\n",
      " |      \n",
      " |      When a matrix contains symbolic entries, the pivot search algorithm\n",
      " |      differs from the case where every entry can be categorized as zero or\n",
      " |      nonzero.\n",
      " |      The algorithm searches column by column through the submatrix whose\n",
      " |      top left entry coincides with the pivot position.\n",
      " |      If it exists, the pivot is the first entry in the current search\n",
      " |      column that iszerofunc guarantees is nonzero.\n",
      " |      If no such candidate exists, then each candidate pivot is simplified\n",
      " |      if simpfunc is not None.\n",
      " |      The search is repeated, with the difference that a candidate may be\n",
      " |      the pivot if ``iszerofunc()`` cannot guarantee that it is nonzero.\n",
      " |      In the second search the pivot is the first candidate that\n",
      " |      iszerofunc can guarantee is nonzero.\n",
      " |      If no such candidate exists, then the pivot is the first candidate\n",
      " |      for which iszerofunc returns None.\n",
      " |      If no such candidate exists, then the search is repeated in the next\n",
      " |      column to the right.\n",
      " |      The pivot search algorithm differs from the one in ``rref()``, which\n",
      " |      relies on ``_find_reasonable_pivot()``.\n",
      " |      Future versions of ``LUdecomposition_simple()`` may use\n",
      " |      ``_find_reasonable_pivot()``.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.matrices.MatrixBase.LUdecomposition\n",
      " |      LUdecompositionFF\n",
      " |      LUsolve\n",
      " |  \n",
      " |  LUsolve(self, rhs, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Solve the linear system ``Ax = rhs`` for ``x`` where ``A = M``.\n",
      " |      \n",
      " |      This is for symbolic matrices, for real or complex ones use\n",
      " |      mpmath.lu_solve or mpmath.qr_solve.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.lower_triangular_solve\n",
      " |      sympy.matrices.dense.DenseMatrix.upper_triangular_solve\n",
      " |      gauss_jordan_solve\n",
      " |      cholesky_solve\n",
      " |      diagonal_solve\n",
      " |      LDLsolve\n",
      " |      QRsolve\n",
      " |      pinv_solve\n",
      " |      LUdecomposition\n",
      " |  \n",
      " |  QRdecomposition(self)\n",
      " |      Returns a QR decomposition.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A QR decomposition is a decomposition in the form $A = Q R$\n",
      " |      where\n",
      " |      \n",
      " |      - $Q$ is a column orthogonal matrix.\n",
      " |      - $R$ is a upper triangular (trapezoidal) matrix.\n",
      " |      \n",
      " |      A column orthogonal matrix satisfies\n",
      " |      $\\mathbb{I} = Q^H Q$ while a full orthogonal matrix satisfies\n",
      " |      relation $\\mathbb{I} = Q Q^H = Q^H Q$ where $I$ is an identity\n",
      " |      matrix with matching dimensions.\n",
      " |      \n",
      " |      For matrices which are not square or are rank-deficient, it is\n",
      " |      sufficient to return a column orthogonal matrix because augmenting\n",
      " |      them may introduce redundant computations.\n",
      " |      And an another advantage of this is that you can easily inspect the\n",
      " |      matrix rank by counting the number of columns of $Q$.\n",
      " |      \n",
      " |      If you want to augment the results to return a full orthogonal\n",
      " |      decomposition, you should use the following procedures.\n",
      " |      \n",
      " |      - Augment the $Q$ matrix with columns that are orthogonal to every\n",
      " |        other columns and make it square.\n",
      " |      - Augument the $R$ matrix with zero rows to make it have the same\n",
      " |        shape as the original matrix.\n",
      " |      \n",
      " |      The procedure will be illustrated in the examples section.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      A full rank matrix example:\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[12, -51, 4], [6, 167, -68], [-4, 24, -41]])\n",
      " |      >>> Q, R = A.QRdecomposition()\n",
      " |      >>> Q\n",
      " |      Matrix([\n",
      " |      [ 6/7, -69/175, -58/175],\n",
      " |      [ 3/7, 158/175,   6/175],\n",
      " |      [-2/7,    6/35,  -33/35]])\n",
      " |      >>> R\n",
      " |      Matrix([\n",
      " |      [14,  21, -14],\n",
      " |      [ 0, 175, -70],\n",
      " |      [ 0,   0,  35]])\n",
      " |      \n",
      " |      If the matrix is square and full rank, the $Q$ matrix becomes\n",
      " |      orthogonal in both directions, and needs no augmentation.\n",
      " |      \n",
      " |      >>> Q * Q.H\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      >>> Q.H * Q\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      \n",
      " |      >>> A == Q*R\n",
      " |      True\n",
      " |      \n",
      " |      A rank deficient matrix example:\n",
      " |      \n",
      " |      >>> A = Matrix([[12, -51, 0], [6, 167, 0], [-4, 24, 0]])\n",
      " |      >>> Q, R = A.QRdecomposition()\n",
      " |      >>> Q\n",
      " |      Matrix([\n",
      " |      [ 6/7, -69/175],\n",
      " |      [ 3/7, 158/175],\n",
      " |      [-2/7,    6/35]])\n",
      " |      >>> R\n",
      " |      Matrix([\n",
      " |      [14,  21, 0],\n",
      " |      [ 0, 175, 0]])\n",
      " |      \n",
      " |      QRdecomposition might return a matrix Q that is rectangular.\n",
      " |      In this case the orthogonality condition might be satisfied as\n",
      " |      $\\mathbb{I} = Q.H*Q$ but not in the reversed product\n",
      " |      $\\mathbb{I} = Q * Q.H$.\n",
      " |      \n",
      " |      >>> Q.H * Q\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]])\n",
      " |      >>> Q * Q.H\n",
      " |      Matrix([\n",
      " |      [27261/30625,   348/30625, -1914/6125],\n",
      " |      [  348/30625, 30589/30625,   198/6125],\n",
      " |      [ -1914/6125,    198/6125,   136/1225]])\n",
      " |      \n",
      " |      If you want to augment the results to be a full orthogonal\n",
      " |      decomposition, you should augment $Q$ with an another orthogonal\n",
      " |      column.\n",
      " |      \n",
      " |      You are able to append an arbitrary standard basis that are linearly\n",
      " |      independent to every other columns and you can run the Gram-Schmidt\n",
      " |      process to make them augmented as orthogonal basis.\n",
      " |      \n",
      " |      >>> Q_aug = Q.row_join(Matrix([0, 0, 1]))\n",
      " |      >>> Q_aug = Q_aug.QRdecomposition()[0]\n",
      " |      >>> Q_aug\n",
      " |      Matrix([\n",
      " |      [ 6/7, -69/175, 58/175],\n",
      " |      [ 3/7, 158/175, -6/175],\n",
      " |      [-2/7,    6/35,  33/35]])\n",
      " |      >>> Q_aug.H * Q_aug\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      >>> Q_aug * Q_aug.H\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      \n",
      " |      Augmenting the $R$ matrix with zero row is straightforward.\n",
      " |      \n",
      " |      >>> R_aug = R.col_join(Matrix([[0, 0, 0]]))\n",
      " |      >>> R_aug\n",
      " |      Matrix([\n",
      " |      [14,  21, 0],\n",
      " |      [ 0, 175, 0],\n",
      " |      [ 0,   0, 0]])\n",
      " |      >>> Q_aug * R_aug == A\n",
      " |      True\n",
      " |      \n",
      " |      A zero matrix example:\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix.zeros(3, 4)\n",
      " |      >>> Q, R = A.QRdecomposition()\n",
      " |      \n",
      " |      They may return matrices with zero rows and columns.\n",
      " |      \n",
      " |      >>> Q\n",
      " |      Matrix(3, 0, [])\n",
      " |      >>> R\n",
      " |      Matrix(0, 4, [])\n",
      " |      >>> Q*R\n",
      " |      Matrix([\n",
      " |      [0, 0, 0, 0],\n",
      " |      [0, 0, 0, 0],\n",
      " |      [0, 0, 0, 0]])\n",
      " |      \n",
      " |      As the same augmentation rule described above, $Q$ can be augmented\n",
      " |      with columns of an identity matrix and $R$ can be augmented with\n",
      " |      rows of a zero matrix.\n",
      " |      \n",
      " |      >>> Q_aug = Q.row_join(Matrix.eye(3))\n",
      " |      >>> R_aug = R.col_join(Matrix.zeros(3, 4))\n",
      " |      >>> Q_aug * Q_aug.T\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      >>> R_aug\n",
      " |      Matrix([\n",
      " |      [0, 0, 0, 0],\n",
      " |      [0, 0, 0, 0],\n",
      " |      [0, 0, 0, 0]])\n",
      " |      >>> Q_aug * R_aug == A\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.cholesky\n",
      " |      sympy.matrices.dense.DenseMatrix.LDLdecomposition\n",
      " |      sympy.matrices.matrices.MatrixBase.LUdecomposition\n",
      " |      QRsolve\n",
      " |  \n",
      " |  QRsolve(self, b)\n",
      " |      Solve the linear system ``Ax = b``.\n",
      " |      \n",
      " |      ``M`` is the matrix ``A``, the method argument is the vector\n",
      " |      ``b``.  The method returns the solution vector ``x``.  If ``b`` is a\n",
      " |      matrix, the system is solved for each column of ``b`` and the\n",
      " |      return value is a matrix of the same shape as ``b``.\n",
      " |      \n",
      " |      This method is slower (approximately by a factor of 2) but\n",
      " |      more stable for floating-point arithmetic than the LUsolve method.\n",
      " |      However, LUsolve usually uses an exact arithmetic, so you do not need\n",
      " |      to use QRsolve.\n",
      " |      \n",
      " |      This is mainly for educational purposes and symbolic matrices, for real\n",
      " |      (or complex) matrices use mpmath.qr_solve.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.lower_triangular_solve\n",
      " |      sympy.matrices.dense.DenseMatrix.upper_triangular_solve\n",
      " |      gauss_jordan_solve\n",
      " |      cholesky_solve\n",
      " |      diagonal_solve\n",
      " |      LDLsolve\n",
      " |      LUsolve\n",
      " |      pinv_solve\n",
      " |      QRdecomposition\n",
      " |  \n",
      " |  __array__(self, dtype=<class 'object'>)\n",
      " |  \n",
      " |  __len__(self)\n",
      " |      Return the number of elements of ``self``.\n",
      " |      \n",
      " |      Implemented mainly so bool(Matrix()) == False.\n",
      " |  \n",
      " |  __str__(self)\n",
      " |      Return str(self).\n",
      " |  \n",
      " |  add(self, b)\n",
      " |      Return self + b\n",
      " |  \n",
      " |  analytic_func(self, f, x)\n",
      " |      Computes f(A) where A is a Square Matrix\n",
      " |      and f is an analytic function.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol, Matrix, S, log\n",
      " |      \n",
      " |      >>> x = Symbol('x')\n",
      " |      >>> m = Matrix([[S(5)/4, S(3)/4], [S(3)/4, S(5)/4]])\n",
      " |      >>> f = log(x)\n",
      " |      >>> m.analytic_func(f, x)\n",
      " |      Matrix([\n",
      " |      [     0, log(2)],\n",
      " |      [log(2),      0]])\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      f : Expr\n",
      " |          Analytic Function\n",
      " |      x : Symbol\n",
      " |          parameter of f\n",
      " |  \n",
      " |  cholesky_solve(self, rhs)\n",
      " |      Solves ``Ax = B`` using Cholesky decomposition,\n",
      " |      for a general square non-singular matrix.\n",
      " |      For a non-square matrix with rows > cols,\n",
      " |      the least squares solution is returned.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.lower_triangular_solve\n",
      " |      sympy.matrices.dense.DenseMatrix.upper_triangular_solve\n",
      " |      gauss_jordan_solve\n",
      " |      diagonal_solve\n",
      " |      LDLsolve\n",
      " |      LUsolve\n",
      " |      QRsolve\n",
      " |      pinv_solve\n",
      " |  \n",
      " |  condition_number(self)\n",
      " |      Returns the condition number of a matrix.\n",
      " |      \n",
      " |      This is the maximum singular value divided by the minimum singular value\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, S\n",
      " |      >>> A = Matrix([[1, 0, 0], [0, 10, 0], [0, 0, S.One/10]])\n",
      " |      >>> A.condition_number()\n",
      " |      100\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      singular_values\n",
      " |  \n",
      " |  connected_components(self)\n",
      " |      Returns the list of connected vertices of the graph when\n",
      " |      a square matrix is viewed as a weighted graph.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([\n",
      " |      ...     [66, 0, 0, 68, 0, 0, 0, 0, 67],\n",
      " |      ...     [0, 55, 0, 0, 0, 0, 54, 53, 0],\n",
      " |      ...     [0, 0, 0, 0, 1, 2, 0, 0, 0],\n",
      " |      ...     [86, 0, 0, 88, 0, 0, 0, 0, 87],\n",
      " |      ...     [0, 0, 10, 0, 11, 12, 0, 0, 0],\n",
      " |      ...     [0, 0, 20, 0, 21, 22, 0, 0, 0],\n",
      " |      ...     [0, 45, 0, 0, 0, 0, 44, 43, 0],\n",
      " |      ...     [0, 35, 0, 0, 0, 0, 34, 33, 0],\n",
      " |      ...     [76, 0, 0, 78, 0, 0, 0, 0, 77]])\n",
      " |      >>> A.connected_components()\n",
      " |      [[0, 3, 8], [1, 6, 7], [2, 4, 5]]\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Even if any symbolic elements of the matrix can be indeterminate\n",
      " |      to be zero mathematically, this only takes the account of the\n",
      " |      structural aspect of the matrix, so they will considered to be\n",
      " |      nonzero.\n",
      " |  \n",
      " |  connected_components_decomposition(self)\n",
      " |      Decomposes a square matrix into block diagonal form only\n",
      " |      using the permutations.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      The decomposition is in a form of $A = P^{-1} B P$ where $P$ is a\n",
      " |      permutation matrix and $B$ is a block diagonal matrix.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      P, B : PermutationMatrix, BlockDiagMatrix\n",
      " |          *P* is a permutation matrix for the similarity transform\n",
      " |          as in the explanation. And *B* is the block diagonal matrix of\n",
      " |          the result of the permutation.\n",
      " |      \n",
      " |          If you would like to get the diagonal blocks from the\n",
      " |          BlockDiagMatrix, see\n",
      " |          :meth:`~sympy.matrices.expressions.blockmatrix.BlockDiagMatrix.get_diag_blocks`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, pprint\n",
      " |      >>> A = Matrix([\n",
      " |      ...     [66, 0, 0, 68, 0, 0, 0, 0, 67],\n",
      " |      ...     [0, 55, 0, 0, 0, 0, 54, 53, 0],\n",
      " |      ...     [0, 0, 0, 0, 1, 2, 0, 0, 0],\n",
      " |      ...     [86, 0, 0, 88, 0, 0, 0, 0, 87],\n",
      " |      ...     [0, 0, 10, 0, 11, 12, 0, 0, 0],\n",
      " |      ...     [0, 0, 20, 0, 21, 22, 0, 0, 0],\n",
      " |      ...     [0, 45, 0, 0, 0, 0, 44, 43, 0],\n",
      " |      ...     [0, 35, 0, 0, 0, 0, 34, 33, 0],\n",
      " |      ...     [76, 0, 0, 78, 0, 0, 0, 0, 77]])\n",
      " |      \n",
      " |      >>> P, B = A.connected_components_decomposition()\n",
      " |      >>> pprint(P)\n",
      " |      PermutationMatrix((1 3)(2 8 5 7 4 6))\n",
      " |      >>> pprint(B)\n",
      " |      [[66  68  67]                            ]\n",
      " |      [[          ]                            ]\n",
      " |      [[86  88  87]       0             0      ]\n",
      " |      [[          ]                            ]\n",
      " |      [[76  78  77]                            ]\n",
      " |      [                                        ]\n",
      " |      [              [55  54  53]              ]\n",
      " |      [              [          ]              ]\n",
      " |      [     0        [45  44  43]       0      ]\n",
      " |      [              [          ]              ]\n",
      " |      [              [35  34  33]              ]\n",
      " |      [                                        ]\n",
      " |      [                            [0   1   2 ]]\n",
      " |      [                            [          ]]\n",
      " |      [     0             0        [10  11  12]]\n",
      " |      [                            [          ]]\n",
      " |      [                            [20  21  22]]\n",
      " |      \n",
      " |      >>> P = P.as_explicit()\n",
      " |      >>> B = B.as_explicit()\n",
      " |      >>> P.T*B*P == A\n",
      " |      True\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      This problem corresponds to the finding of the connected components\n",
      " |      of a graph, when a matrix is viewed as a weighted graph.\n",
      " |  \n",
      " |  cross(self, b)\n",
      " |      Return the cross product of ``self`` and ``b`` relaxing the condition\n",
      " |      of compatible dimensions: if each has 3 elements, a matrix of the\n",
      " |      same type and shape as ``self`` will be returned. If ``b`` has the same\n",
      " |      shape as ``self`` then common identities for the cross product (like\n",
      " |      `a \\times b = - b \\times a`) will hold.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |          b : 3x1 or 1x3 Matrix\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      dot\n",
      " |      multiply\n",
      " |      multiply_elementwise\n",
      " |  \n",
      " |  diagonal_solve(self, rhs)\n",
      " |      Solves ``Ax = B`` efficiently, where A is a diagonal Matrix,\n",
      " |      with non-zero diagonal entries.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, eye\n",
      " |      >>> A = eye(2)*2\n",
      " |      >>> B = Matrix([[1, 2], [3, 4]])\n",
      " |      >>> A.diagonal_solve(B) == B/2\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.lower_triangular_solve\n",
      " |      sympy.matrices.dense.DenseMatrix.upper_triangular_solve\n",
      " |      gauss_jordan_solve\n",
      " |      cholesky_solve\n",
      " |      LDLsolve\n",
      " |      LUsolve\n",
      " |      QRsolve\n",
      " |      pinv_solve\n",
      " |  \n",
      " |  dot(self, b, hermitian=None, conjugate_convention=None)\n",
      " |      Return the dot or inner product of two vectors of equal length.\n",
      " |      Here ``self`` must be a ``Matrix`` of size 1 x n or n x 1, and ``b``\n",
      " |      must be either a matrix of size 1 x n, n x 1, or a list/tuple of length n.\n",
      " |      A scalar is returned.\n",
      " |      \n",
      " |      By default, ``dot`` does not conjugate ``self`` or ``b``, even if there are\n",
      " |      complex entries. Set ``hermitian=True`` (and optionally a ``conjugate_convention``)\n",
      " |      to compute the hermitian inner product.\n",
      " |      \n",
      " |      Possible kwargs are ``hermitian`` and ``conjugate_convention``.\n",
      " |      \n",
      " |      If ``conjugate_convention`` is ``\"left\"``, ``\"math\"`` or ``\"maths\"``,\n",
      " |      the conjugate of the first vector (``self``) is used.  If ``\"right\"``\n",
      " |      or ``\"physics\"`` is specified, the conjugate of the second vector ``b`` is used.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n",
      " |      >>> v = Matrix([1, 1, 1])\n",
      " |      >>> M.row(0).dot(v)\n",
      " |      6\n",
      " |      >>> M.col(0).dot(v)\n",
      " |      12\n",
      " |      >>> v = [3, 2, 1]\n",
      " |      >>> M.row(0).dot(v)\n",
      " |      10\n",
      " |      \n",
      " |      >>> from sympy import I\n",
      " |      >>> q = Matrix([1*I, 1*I, 1*I])\n",
      " |      >>> q.dot(q, hermitian=False)\n",
      " |      -3\n",
      " |      \n",
      " |      >>> q.dot(q, hermitian=True)\n",
      " |      3\n",
      " |      \n",
      " |      >>> q1 = Matrix([1, 1, 1*I])\n",
      " |      >>> q.dot(q1, hermitian=True, conjugate_convention=\"maths\")\n",
      " |      1 - 2*I\n",
      " |      >>> q.dot(q1, hermitian=True, conjugate_convention=\"physics\")\n",
      " |      1 + 2*I\n",
      " |      \n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      cross\n",
      " |      multiply\n",
      " |      multiply_elementwise\n",
      " |  \n",
      " |  dual(self)\n",
      " |      Returns the dual of a matrix, which is:\n",
      " |      \n",
      " |      ``(1/2)*levicivita(i, j, k, l)*M(k, l)`` summed over indices `k` and `l`\n",
      " |      \n",
      " |      Since the levicivita method is anti_symmetric for any pairwise\n",
      " |      exchange of indices, the dual of a symmetric matrix is the zero\n",
      " |      matrix. Strictly speaking the dual defined here assumes that the\n",
      " |      'matrix' `M` is a contravariant anti_symmetric second rank tensor,\n",
      " |      so that the dual is a covariant second rank tensor.\n",
      " |  \n",
      " |  exp(self)\n",
      " |      Return the exponential of a square matrix\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol, Matrix\n",
      " |      \n",
      " |      >>> t = Symbol('t')\n",
      " |      >>> m = Matrix([[0, 1], [-1, 0]]) * t\n",
      " |      >>> m.exp()\n",
      " |      Matrix([\n",
      " |      [    exp(I*t)/2 + exp(-I*t)/2, -I*exp(I*t)/2 + I*exp(-I*t)/2],\n",
      " |      [I*exp(I*t)/2 - I*exp(-I*t)/2,      exp(I*t)/2 + exp(-I*t)/2]])\n",
      " |  \n",
      " |  gauss_jordan_solve(self, B, freevar=False)\n",
      " |      Solves ``Ax = B`` using Gauss Jordan elimination.\n",
      " |      \n",
      " |      There may be zero, one, or infinite solutions.  If one solution\n",
      " |      exists, it will be returned. If infinite solutions exist, it will\n",
      " |      be returned parametrically. If no solutions exist, It will throw\n",
      " |      ValueError.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      B : Matrix\n",
      " |          The right hand side of the equation to be solved for.  Must have\n",
      " |          the same number of rows as matrix A.\n",
      " |      \n",
      " |      freevar : boolean, optional\n",
      " |          Flag, when set to `True` will return the indices of the free\n",
      " |          variables in the solutions (column Matrix), for a system that is\n",
      " |          undetermined (e.g. A has more columns than rows), for which\n",
      " |          infinite solutions are possible, in terms of arbitrary\n",
      " |          values of free variables. Default `False`.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      x : Matrix\n",
      " |          The matrix that will satisfy ``Ax = B``.  Will have as many rows as\n",
      " |          matrix A has columns, and as many columns as matrix B.\n",
      " |      \n",
      " |      params : Matrix\n",
      " |          If the system is underdetermined (e.g. A has more columns than\n",
      " |          rows), infinite solutions are possible, in terms of arbitrary\n",
      " |          parameters. These arbitrary parameters are returned as params\n",
      " |          Matrix.\n",
      " |      \n",
      " |      free_var_index : List, optional\n",
      " |          If the system is underdetermined (e.g. A has more columns than\n",
      " |          rows), infinite solutions are possible, in terms of arbitrary\n",
      " |          values of free variables. Then the indices of the free variables\n",
      " |          in the solutions (column Matrix) are returned by free_var_index,\n",
      " |          if the flag `freevar` is set to `True`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[1, 2, 1, 1], [1, 2, 2, -1], [2, 4, 0, 6]])\n",
      " |      >>> B = Matrix([7, 12, 4])\n",
      " |      >>> sol, params = A.gauss_jordan_solve(B)\n",
      " |      >>> sol\n",
      " |      Matrix([\n",
      " |      [-2*tau0 - 3*tau1 + 2],\n",
      " |      [                 tau0],\n",
      " |      [           2*tau1 + 5],\n",
      " |      [                 tau1]])\n",
      " |      >>> params\n",
      " |      Matrix([\n",
      " |      [tau0],\n",
      " |      [tau1]])\n",
      " |      >>> taus_zeroes = { tau:0 for tau in params }\n",
      " |      >>> sol_unique = sol.xreplace(taus_zeroes)\n",
      " |      >>> sol_unique\n",
      " |          Matrix([\n",
      " |      [2],\n",
      " |      [0],\n",
      " |      [5],\n",
      " |      [0]])\n",
      " |      \n",
      " |      \n",
      " |      >>> A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 10]])\n",
      " |      >>> B = Matrix([3, 6, 9])\n",
      " |      >>> sol, params = A.gauss_jordan_solve(B)\n",
      " |      >>> sol\n",
      " |      Matrix([\n",
      " |      [-1],\n",
      " |      [ 2],\n",
      " |      [ 0]])\n",
      " |      >>> params\n",
      " |      Matrix(0, 1, [])\n",
      " |      \n",
      " |      >>> A = Matrix([[2, -7], [-1, 4]])\n",
      " |      >>> B = Matrix([[-21, 3], [12, -2]])\n",
      " |      >>> sol, params = A.gauss_jordan_solve(B)\n",
      " |      >>> sol\n",
      " |      Matrix([\n",
      " |      [0, -2],\n",
      " |      [3, -1]])\n",
      " |      >>> params\n",
      " |      Matrix(0, 2, [])\n",
      " |      \n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[1, 2, 1, 1], [1, 2, 2, -1], [2, 4, 0, 6]])\n",
      " |      >>> B = Matrix([7, 12, 4])\n",
      " |      >>> sol, params, freevars = A.gauss_jordan_solve(B, freevar=True)\n",
      " |      >>> sol\n",
      " |      Matrix([\n",
      " |      [-2*tau0 - 3*tau1 + 2],\n",
      " |      [                 tau0],\n",
      " |      [           2*tau1 + 5],\n",
      " |      [                 tau1]])\n",
      " |      >>> params\n",
      " |      Matrix([\n",
      " |      [tau0],\n",
      " |      [tau1]])\n",
      " |      >>> freevars\n",
      " |      [1, 3]\n",
      " |      \n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.lower_triangular_solve\n",
      " |      sympy.matrices.dense.DenseMatrix.upper_triangular_solve\n",
      " |      cholesky_solve\n",
      " |      diagonal_solve\n",
      " |      LDLsolve\n",
      " |      LUsolve\n",
      " |      QRsolve\n",
      " |      pinv\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Gaussian_elimination\n",
      " |  \n",
      " |  inv(self, method=None, iszerofunc=<function _iszero at 0x7f27787b60d0>, try_block_diag=False)\n",
      " |      Return the inverse of a matrix using the method indicated. Default for\n",
      " |      dense matrices is is Gauss elimination, default for sparse matrices is LDL.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      method : ('GE', 'LU', 'ADJ', 'CH', 'LDL')\n",
      " |      \n",
      " |      iszerofunc : function, optional\n",
      " |          Zero-testing function to use.\n",
      " |      \n",
      " |      try_block_diag : bool, optional\n",
      " |          If True then will try to form block diagonal matrices using the\n",
      " |          method get_diag_blocks(), invert these individually, and then\n",
      " |          reconstruct the full inverse matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import SparseMatrix, Matrix\n",
      " |      >>> A = SparseMatrix([\n",
      " |      ... [ 2, -1,  0],\n",
      " |      ... [-1,  2, -1],\n",
      " |      ... [ 0,  0,  2]])\n",
      " |      >>> A.inv('CH')\n",
      " |      Matrix([\n",
      " |      [2/3, 1/3, 1/6],\n",
      " |      [1/3, 2/3, 1/3],\n",
      " |      [  0,   0, 1/2]])\n",
      " |      >>> A.inv(method='LDL') # use of 'method=' is optional\n",
      " |      Matrix([\n",
      " |      [2/3, 1/3, 1/6],\n",
      " |      [1/3, 2/3, 1/3],\n",
      " |      [  0,   0, 1/2]])\n",
      " |      >>> A * _\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      >>> A = Matrix(A)\n",
      " |      >>> A.inv('CH')\n",
      " |      Matrix([\n",
      " |      [2/3, 1/3, 1/6],\n",
      " |      [1/3, 2/3, 1/3],\n",
      " |      [  0,   0, 1/2]])\n",
      " |      >>> A.inv('ADJ') == A.inv('GE') == A.inv('LU') == A.inv('CH') == A.inv('LDL') == A.inv('QR')\n",
      " |      True\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      According to the ``method`` keyword, it calls the appropriate method:\n",
      " |      \n",
      " |          GE .... inverse_GE(); default for dense matrices\n",
      " |          LU .... inverse_LU()\n",
      " |          ADJ ... inverse_ADJ()\n",
      " |          CH ... inverse_CH()\n",
      " |          LDL ... inverse_LDL(); default for sparse matrices\n",
      " |          QR ... inverse_QR()\n",
      " |      \n",
      " |      Note, the GE and LU methods may require the matrix to be simplified\n",
      " |      before it is inverted in order to properly detect zeros during\n",
      " |      pivoting. In difficult cases a custom zero detection function can\n",
      " |      be provided by setting the ``iszerofunc`` argument to a function that\n",
      " |      should return True if its argument is zero. The ADJ routine computes\n",
      " |      the determinant and uses that to detect singular matrices in addition\n",
      " |      to testing for zeros on the diagonal.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      inverse_ADJ\n",
      " |      inverse_GE\n",
      " |      inverse_LU\n",
      " |      inverse_CH\n",
      " |      inverse_LDL\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      ValueError\n",
      " |          If the determinant of the matrix is zero.\n",
      " |  \n",
      " |  inv_mod(self, m)\n",
      " |      Returns the inverse of the matrix `K` (mod `m`), if it exists.\n",
      " |      \n",
      " |      Method to find the matrix inverse of `K` (mod `m`) implemented in this function:\n",
      " |      \n",
      " |      * Compute `\\mathrm{adj}(K) = \\mathrm{cof}(K)^t`, the adjoint matrix of `K`.\n",
      " |      \n",
      " |      * Compute `r = 1/\\mathrm{det}(K) \\pmod m`.\n",
      " |      \n",
      " |      * `K^{-1} = r\\cdot \\mathrm{adj}(K) \\pmod m`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix(2, 2, [1, 2, 3, 4])\n",
      " |      >>> A.inv_mod(5)\n",
      " |      Matrix([\n",
      " |      [3, 1],\n",
      " |      [4, 2]])\n",
      " |      >>> A.inv_mod(3)\n",
      " |      Matrix([\n",
      " |      [1, 1],\n",
      " |      [0, 1]])\n",
      " |  \n",
      " |  inverse_ADJ(self, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Calculates the inverse using the adjugate matrix and a determinant.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      inv\n",
      " |      inverse_GE\n",
      " |      inverse_LU\n",
      " |      inverse_CH\n",
      " |      inverse_LDL\n",
      " |  \n",
      " |  inverse_BLOCK(self, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Calculates the inverse using BLOCKWISE inversion.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      inv\n",
      " |      inverse_ADJ\n",
      " |      inverse_GE\n",
      " |      inverse_CH\n",
      " |      inverse_LDL\n",
      " |  \n",
      " |  inverse_CH(self, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Calculates the inverse using cholesky decomposition.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      inv\n",
      " |      inverse_ADJ\n",
      " |      inverse_GE\n",
      " |      inverse_LU\n",
      " |      inverse_LDL\n",
      " |  \n",
      " |  inverse_GE(self, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Calculates the inverse using Gaussian elimination.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      inv\n",
      " |      inverse_ADJ\n",
      " |      inverse_LU\n",
      " |      inverse_CH\n",
      " |      inverse_LDL\n",
      " |  \n",
      " |  inverse_LDL(self, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Calculates the inverse using LDL decomposition.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      inv\n",
      " |      inverse_ADJ\n",
      " |      inverse_GE\n",
      " |      inverse_LU\n",
      " |      inverse_CH\n",
      " |  \n",
      " |  inverse_LU(self, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Calculates the inverse using LU decomposition.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      inv\n",
      " |      inverse_ADJ\n",
      " |      inverse_GE\n",
      " |      inverse_CH\n",
      " |      inverse_LDL\n",
      " |  \n",
      " |  inverse_QR(self, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Calculates the inverse using QR decomposition.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      inv\n",
      " |      inverse_ADJ\n",
      " |      inverse_GE\n",
      " |      inverse_CH\n",
      " |      inverse_LDL\n",
      " |  \n",
      " |  is_nilpotent(self)\n",
      " |      Checks if a matrix is nilpotent.\n",
      " |      \n",
      " |      A matrix B is nilpotent if for some integer k, B**k is\n",
      " |      a zero matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> a = Matrix([[0, 0, 0], [1, 0, 0], [1, 1, 0]])\n",
      " |      >>> a.is_nilpotent()\n",
      " |      True\n",
      " |      \n",
      " |      >>> a = Matrix([[1, 0, 1], [1, 0, 0], [1, 1, 0]])\n",
      " |      >>> a.is_nilpotent()\n",
      " |      False\n",
      " |  \n",
      " |  key2bounds(self, keys)\n",
      " |      Converts a key with potentially mixed types of keys (integer and slice)\n",
      " |      into a tuple of ranges and raises an error if any index is out of ``self``'s\n",
      " |      range.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      key2ij\n",
      " |  \n",
      " |  key2ij(self, key)\n",
      " |      Converts key into canonical form, converting integers or indexable\n",
      " |      items into valid integers for ``self``'s range or returning slices\n",
      " |      unchanged.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      key2bounds\n",
      " |  \n",
      " |  log(self, simplify=<function cancel at 0x7f2778d9c940>)\n",
      " |      Return the logarithm of a square matrix\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      simplify : function, bool\n",
      " |          The function to simplify the result with.\n",
      " |      \n",
      " |          Default is ``cancel``, which is effective to reduce the\n",
      " |          expression growing for taking reciprocals and inverses for\n",
      " |          symbolic matrices.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import S, Matrix\n",
      " |      \n",
      " |      Examples for positive-definite matrices:\n",
      " |      \n",
      " |      >>> m = Matrix([[1, 1], [0, 1]])\n",
      " |      >>> m.log()\n",
      " |      Matrix([\n",
      " |      [0, 1],\n",
      " |      [0, 0]])\n",
      " |      \n",
      " |      >>> m = Matrix([[S(5)/4, S(3)/4], [S(3)/4, S(5)/4]])\n",
      " |      >>> m.log()\n",
      " |      Matrix([\n",
      " |      [     0, log(2)],\n",
      " |      [log(2),      0]])\n",
      " |      \n",
      " |      Examples for non positive-definite matrices:\n",
      " |      \n",
      " |      >>> m = Matrix([[S(3)/4, S(5)/4], [S(5)/4, S(3)/4]])\n",
      " |      >>> m.log()\n",
      " |      Matrix([\n",
      " |      [         I*pi/2, log(2) - I*pi/2],\n",
      " |      [log(2) - I*pi/2,          I*pi/2]])\n",
      " |      \n",
      " |      >>> m = Matrix(\n",
      " |      ...     [[0, 0, 0, 1],\n",
      " |      ...      [0, 0, 1, 0],\n",
      " |      ...      [0, 1, 0, 0],\n",
      " |      ...      [1, 0, 0, 0]])\n",
      " |      >>> m.log()\n",
      " |      Matrix([\n",
      " |      [ I*pi/2,       0,       0, -I*pi/2],\n",
      " |      [      0,  I*pi/2, -I*pi/2,       0],\n",
      " |      [      0, -I*pi/2,  I*pi/2,       0],\n",
      " |      [-I*pi/2,       0,       0,  I*pi/2]])\n",
      " |  \n",
      " |  norm(self, ord=None)\n",
      " |      Return the Norm of a Matrix or Vector.\n",
      " |      In the simplest case this is the geometric size of the vector\n",
      " |      Other norms can be specified by the ord parameter\n",
      " |      \n",
      " |      \n",
      " |      =====  ============================  ==========================\n",
      " |      ord    norm for matrices             norm for vectors\n",
      " |      =====  ============================  ==========================\n",
      " |      None   Frobenius norm                2-norm\n",
      " |      'fro'  Frobenius norm                - does not exist\n",
      " |      inf    maximum row sum               max(abs(x))\n",
      " |      -inf   --                            min(abs(x))\n",
      " |      1      maximum column sum            as below\n",
      " |      -1     --                            as below\n",
      " |      2      2-norm (largest sing. value)  as below\n",
      " |      -2     smallest singular value       as below\n",
      " |      other  - does not exist              sum(abs(x)**ord)**(1./ord)\n",
      " |      =====  ============================  ==========================\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, Symbol, trigsimp, cos, sin, oo\n",
      " |      >>> x = Symbol('x', real=True)\n",
      " |      >>> v = Matrix([cos(x), sin(x)])\n",
      " |      >>> trigsimp( v.norm() )\n",
      " |      1\n",
      " |      >>> v.norm(10)\n",
      " |      (sin(x)**10 + cos(x)**10)**(1/10)\n",
      " |      >>> A = Matrix([[1, 1], [1, 1]])\n",
      " |      >>> A.norm(1) # maximum sum of absolute values of A is 2\n",
      " |      2\n",
      " |      >>> A.norm(2) # Spectral norm (max of |Ax|/|x| under 2-vector-norm)\n",
      " |      2\n",
      " |      >>> A.norm(-2) # Inverse spectral norm (smallest singular value)\n",
      " |      0\n",
      " |      >>> A.norm() # Frobenius Norm\n",
      " |      2\n",
      " |      >>> A.norm(oo) # Infinity Norm\n",
      " |      2\n",
      " |      >>> Matrix([1, -2]).norm(oo)\n",
      " |      2\n",
      " |      >>> Matrix([-1, 2]).norm(-oo)\n",
      " |      1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      normalized\n",
      " |  \n",
      " |  normalized(self, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Return the normalized version of ``self``.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      iszerofunc : Function, optional\n",
      " |          A function to determine whether ``self`` is a zero vector.\n",
      " |          The default ``_iszero`` tests to see if each element is\n",
      " |          exactly zero.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      Matrix\n",
      " |          Normalized vector form of ``self``.\n",
      " |          It has the same length as a unit vector. However, a zero vector\n",
      " |          will be returned for a vector with norm 0.\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      ShapeError\n",
      " |          If the matrix is not in a vector form.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      norm\n",
      " |  \n",
      " |  pinv(self, method='RD')\n",
      " |      Calculate the Moore-Penrose pseudoinverse of the matrix.\n",
      " |      \n",
      " |      The Moore-Penrose pseudoinverse exists and is unique for any matrix.\n",
      " |      If the matrix is invertible, the pseudoinverse is the same as the\n",
      " |      inverse.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      method : String, optional\n",
      " |          Specifies the method for computing the pseudoinverse.\n",
      " |      \n",
      " |          If ``'RD'``, Rank-Decomposition will be used.\n",
      " |      \n",
      " |          If ``'ED'``, Diagonalization will be used.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      Computing pseudoinverse by rank decomposition :\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[1, 2, 3], [4, 5, 6]])\n",
      " |      >>> A.pinv()\n",
      " |      Matrix([\n",
      " |      [-17/18,  4/9],\n",
      " |      [  -1/9,  1/9],\n",
      " |      [ 13/18, -2/9]])\n",
      " |      \n",
      " |      Computing pseudoinverse by diagonalization :\n",
      " |      \n",
      " |      >>> B = A.pinv(method='ED')\n",
      " |      >>> B.simplify()\n",
      " |      >>> B\n",
      " |      Matrix([\n",
      " |      [-17/18,  4/9],\n",
      " |      [  -1/9,  1/9],\n",
      " |      [ 13/18, -2/9]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      inv\n",
      " |      pinv_solve\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Moore-Penrose_pseudoinverse\n",
      " |  \n",
      " |  pinv_solve(self, B, arbitrary_matrix=None)\n",
      " |      Solve ``Ax = B`` using the Moore-Penrose pseudoinverse.\n",
      " |      \n",
      " |      There may be zero, one, or infinite solutions.  If one solution\n",
      " |      exists, it will be returned.  If infinite solutions exist, one will\n",
      " |      be returned based on the value of arbitrary_matrix.  If no solutions\n",
      " |      exist, the least-squares solution is returned.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      B : Matrix\n",
      " |          The right hand side of the equation to be solved for.  Must have\n",
      " |          the same number of rows as matrix A.\n",
      " |      arbitrary_matrix : Matrix\n",
      " |          If the system is underdetermined (e.g. A has more columns than\n",
      " |          rows), infinite solutions are possible, in terms of an arbitrary\n",
      " |          matrix.  This parameter may be set to a specific matrix to use\n",
      " |          for that purpose; if so, it must be the same shape as x, with as\n",
      " |          many rows as matrix A has columns, and as many columns as matrix\n",
      " |          B.  If left as None, an appropriate matrix containing dummy\n",
      " |          symbols in the form of ``wn_m`` will be used, with n and m being\n",
      " |          row and column position of each symbol.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      x : Matrix\n",
      " |          The matrix that will satisfy ``Ax = B``.  Will have as many rows as\n",
      " |          matrix A has columns, and as many columns as matrix B.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[1, 2, 3], [4, 5, 6]])\n",
      " |      >>> B = Matrix([7, 8])\n",
      " |      >>> A.pinv_solve(B)\n",
      " |      Matrix([\n",
      " |      [ _w0_0/6 - _w1_0/3 + _w2_0/6 - 55/18],\n",
      " |      [-_w0_0/3 + 2*_w1_0/3 - _w2_0/3 + 1/9],\n",
      " |      [ _w0_0/6 - _w1_0/3 + _w2_0/6 + 59/18]])\n",
      " |      >>> A.pinv_solve(B, arbitrary_matrix=Matrix([0, 0, 0]))\n",
      " |      Matrix([\n",
      " |      [-55/18],\n",
      " |      [   1/9],\n",
      " |      [ 59/18]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.dense.DenseMatrix.lower_triangular_solve\n",
      " |      sympy.matrices.dense.DenseMatrix.upper_triangular_solve\n",
      " |      gauss_jordan_solve\n",
      " |      cholesky_solve\n",
      " |      diagonal_solve\n",
      " |      LDLsolve\n",
      " |      LUsolve\n",
      " |      QRsolve\n",
      " |      pinv\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      This may return either exact solutions or least squares solutions.\n",
      " |      To determine which, check ``A * A.pinv() * B == B``.  It will be\n",
      " |      True if exact solutions exist, and False if only a least-squares\n",
      " |      solution exists.  Be aware that the left hand side of that equation\n",
      " |      may need to be simplified to correctly compare to the right hand\n",
      " |      side.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Moore-Penrose_pseudoinverse#Obtaining_all_solutions_of_a_linear_system\n",
      " |  \n",
      " |  print_nonzero(self, symb='X')\n",
      " |      Shows location of non-zero entries for fast shape lookup.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, eye\n",
      " |      >>> m = Matrix(2, 3, lambda i, j: i*3+j)\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [0, 1, 2],\n",
      " |      [3, 4, 5]])\n",
      " |      >>> m.print_nonzero()\n",
      " |      [ XX]\n",
      " |      [XXX]\n",
      " |      >>> m = eye(4)\n",
      " |      >>> m.print_nonzero(\"x\")\n",
      " |      [x   ]\n",
      " |      [ x  ]\n",
      " |      [  x ]\n",
      " |      [   x]\n",
      " |  \n",
      " |  project(self, v)\n",
      " |      Return the projection of ``self`` onto the line containing ``v``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, S, sqrt\n",
      " |      >>> V = Matrix([sqrt(3)/2, S.Half])\n",
      " |      >>> x = Matrix([[1, 0]])\n",
      " |      >>> V.project(x)\n",
      " |      Matrix([[sqrt(3)/2, 0]])\n",
      " |      >>> V.project(-x)\n",
      " |      Matrix([[sqrt(3)/2, 0]])\n",
      " |  \n",
      " |  rank_decomposition(self, iszerofunc=<function _iszero at 0x7f27787b60d0>, simplify=False)\n",
      " |      Returns a pair of matrices (`C`, `F`) with matching rank\n",
      " |      such that `A = C F`.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      iszerofunc : Function, optional\n",
      " |          A function used for detecting whether an element can\n",
      " |          act as a pivot.  ``lambda x: x.is_zero`` is used by default.\n",
      " |      \n",
      " |      simplify : Bool or Function, optional\n",
      " |          A function used to simplify elements when looking for a\n",
      " |          pivot. By default SymPy's ``simplify`` is used.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      (C, F) : Matrices\n",
      " |          `C` and `F` are full-rank matrices with rank as same as `A`,\n",
      " |          whose product gives `A`.\n",
      " |      \n",
      " |          See Notes for additional mathematical details.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([\n",
      " |      ...     [1, 3, 1, 4],\n",
      " |      ...     [2, 7, 3, 9],\n",
      " |      ...     [1, 5, 3, 1],\n",
      " |      ...     [1, 2, 0, 8]\n",
      " |      ... ])\n",
      " |      >>> C, F = A.rank_decomposition()\n",
      " |      >>> C\n",
      " |      Matrix([\n",
      " |      [1, 3, 4],\n",
      " |      [2, 7, 9],\n",
      " |      [1, 5, 1],\n",
      " |      [1, 2, 8]])\n",
      " |      >>> F\n",
      " |      Matrix([\n",
      " |      [1, 0, -2, 0],\n",
      " |      [0, 1,  1, 0],\n",
      " |      [0, 0,  0, 1]])\n",
      " |      >>> C * F == A\n",
      " |      True\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Obtaining `F`, an RREF of `A`, is equivalent to creating a\n",
      " |      product\n",
      " |      \n",
      " |      .. math::\n",
      " |          E_n E_{n-1} ... E_1 A = F\n",
      " |      \n",
      " |      where `E_n, E_{n-1}, \\dots, E_1` are the elimination matrices or\n",
      " |      permutation matrices equivalent to each row-reduction step.\n",
      " |      \n",
      " |      The inverse of the same product of elimination matrices gives\n",
      " |      `C`:\n",
      " |      \n",
      " |      .. math::\n",
      " |          C = \\left(E_n E_{n-1} \\dots E_1\\right)^{-1}\n",
      " |      \n",
      " |      It is not necessary, however, to actually compute the inverse:\n",
      " |      the columns of `C` are those from the original matrix with the\n",
      " |      same column indices as the indices of the pivot columns of `F`.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Rank_factorization\n",
      " |      \n",
      " |      .. [2] Piziak, R.; Odell, P. L. (1 June 1999).\n",
      " |          \"Full Rank Factorization of Matrices\".\n",
      " |          Mathematics Magazine. 72 (3): 193. doi:10.2307/2690882\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.matrices.MatrixReductions.rref\n",
      " |  \n",
      " |  singular_value_decomposition(self)\n",
      " |      Returns a Condensed Singular Value decomposition.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A Singular Value decomposition is a decomposition in the form $A = U \\Sigma V$\n",
      " |      where\n",
      " |      \n",
      " |      - $U, V$ are column orthogonal matrix.\n",
      " |      - $\\Sigma$ is a diagonal matrix, where the main diagonal contains singular\n",
      " |        values of matrix A.\n",
      " |      \n",
      " |      A column orthogonal matrix satisfies\n",
      " |      $\\mathbb{I} = U^H U$ while a full orthogonal matrix satisfies\n",
      " |      relation $\\mathbb{I} = U U^H = U^H U$ where $\\mathbb{I}$ is an identity\n",
      " |      matrix with matching dimensions.\n",
      " |      \n",
      " |      For matrices which are not square or are rank-deficient, it is\n",
      " |      sufficient to return a column orthogonal matrix because augmenting\n",
      " |      them may introduce redundant computations.\n",
      " |      In condensed Singular Value Decomposition we only return column orthognal\n",
      " |      matrices because of this reason\n",
      " |      \n",
      " |      If you want to augment the results to return a full orthogonal\n",
      " |      decomposition, you should use the following procedures.\n",
      " |      \n",
      " |      - Augment the $U, V$ matrices with columns that are orthogonal to every\n",
      " |        other columns and make it square.\n",
      " |      - Augument the $\\Sigma$ matrix with zero rows to make it have the same\n",
      " |        shape as the original matrix.\n",
      " |      \n",
      " |      The procedure will be illustrated in the examples section.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      we take a full rank matrix first:\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[1, 2],[2,1]])\n",
      " |      >>> U, S, V = A.singular_value_decomposition()\n",
      " |      >>> U\n",
      " |      Matrix([\n",
      " |      [ sqrt(2)/2, sqrt(2)/2],\n",
      " |      [-sqrt(2)/2, sqrt(2)/2]])\n",
      " |      >>> S\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 3]])\n",
      " |      >>> V\n",
      " |      Matrix([\n",
      " |      [-sqrt(2)/2, sqrt(2)/2],\n",
      " |      [ sqrt(2)/2, sqrt(2)/2]])\n",
      " |      \n",
      " |      If a matrix if square and full rank both U, V\n",
      " |      are orthogonal in both directions\n",
      " |      \n",
      " |      >>> U * U.H\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]])\n",
      " |      >>> U.H * U\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]])\n",
      " |      \n",
      " |      >>> V * V.H\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]])\n",
      " |      >>> V.H * V\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]])\n",
      " |      >>> A == U * S * V.H\n",
      " |      True\n",
      " |      \n",
      " |      >>> C = Matrix([\n",
      " |      ...         [1, 0, 0, 0, 2],\n",
      " |      ...         [0, 0, 3, 0, 0],\n",
      " |      ...         [0, 0, 0, 0, 0],\n",
      " |      ...         [0, 2, 0, 0, 0],\n",
      " |      ...     ])\n",
      " |      >>> U, S, V = C.singular_value_decomposition()\n",
      " |      \n",
      " |      >>> V.H * V\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 1, 0],\n",
      " |      [0, 0, 1]])\n",
      " |      >>> V * V.H\n",
      " |      Matrix([\n",
      " |      [1/5, 0, 0, 0, 2/5],\n",
      " |      [  0, 1, 0, 0,   0],\n",
      " |      [  0, 0, 1, 0,   0],\n",
      " |      [  0, 0, 0, 0,   0],\n",
      " |      [2/5, 0, 0, 0, 4/5]])\n",
      " |      \n",
      " |      If you want to augment the results to be a full orthogonal\n",
      " |      decomposition, you should augment $V$ with an another orthogonal\n",
      " |      column.\n",
      " |      \n",
      " |      You are able to append an arbitrary standard basis that are linearly\n",
      " |      independent to every other columns and you can run the Gram-Schmidt\n",
      " |      process to make them augmented as orthogonal basis.\n",
      " |      \n",
      " |      >>> V_aug = V.row_join(Matrix([[0,0,0,0,1],\n",
      " |      ... [0,0,0,1,0]]).H)\n",
      " |      >>> V_aug = V_aug.QRdecomposition()[0]\n",
      " |      >>> V_aug\n",
      " |      Matrix([\n",
      " |      [0,   sqrt(5)/5, 0, -2*sqrt(5)/5, 0],\n",
      " |      [1,           0, 0,            0, 0],\n",
      " |      [0,           0, 1,            0, 0],\n",
      " |      [0,           0, 0,            0, 1],\n",
      " |      [0, 2*sqrt(5)/5, 0,    sqrt(5)/5, 0]])\n",
      " |      >>> V_aug.H * V_aug\n",
      " |      Matrix([\n",
      " |      [1, 0, 0, 0, 0],\n",
      " |      [0, 1, 0, 0, 0],\n",
      " |      [0, 0, 1, 0, 0],\n",
      " |      [0, 0, 0, 1, 0],\n",
      " |      [0, 0, 0, 0, 1]])\n",
      " |      >>> V_aug * V_aug.H\n",
      " |      Matrix([\n",
      " |      [1, 0, 0, 0, 0],\n",
      " |      [0, 1, 0, 0, 0],\n",
      " |      [0, 0, 1, 0, 0],\n",
      " |      [0, 0, 0, 1, 0],\n",
      " |      [0, 0, 0, 0, 1]])\n",
      " |      \n",
      " |      Similarly we augment U\n",
      " |      \n",
      " |      >>> U_aug = U.row_join(Matrix([0,0,1,0]))\n",
      " |      >>> U_aug = U_aug.QRdecomposition()[0]\n",
      " |      >>> U_aug\n",
      " |      Matrix([\n",
      " |      [0, 1, 0, 0],\n",
      " |      [0, 0, 1, 0],\n",
      " |      [0, 0, 0, 1],\n",
      " |      [1, 0, 0, 0]])\n",
      " |      \n",
      " |      >>> U_aug.H * U_aug\n",
      " |      Matrix([\n",
      " |      [1, 0, 0, 0],\n",
      " |      [0, 1, 0, 0],\n",
      " |      [0, 0, 1, 0],\n",
      " |      [0, 0, 0, 1]])\n",
      " |      >>> U_aug * U_aug.H\n",
      " |      Matrix([\n",
      " |      [1, 0, 0, 0],\n",
      " |      [0, 1, 0, 0],\n",
      " |      [0, 0, 1, 0],\n",
      " |      [0, 0, 0, 1]])\n",
      " |      \n",
      " |      We add 2 zero columns and one row to S\n",
      " |      \n",
      " |      >>> S_aug = S.col_join(Matrix([[0,0,0]]))\n",
      " |      >>> S_aug = S_aug.row_join(Matrix([[0,0,0,0],\n",
      " |      ... [0,0,0,0]]).H)\n",
      " |      >>> S_aug\n",
      " |      Matrix([\n",
      " |      [2,       0, 0, 0, 0],\n",
      " |      [0, sqrt(5), 0, 0, 0],\n",
      " |      [0,       0, 3, 0, 0],\n",
      " |      [0,       0, 0, 0, 0]])\n",
      " |      \n",
      " |      \n",
      " |      \n",
      " |      >>> U_aug * S_aug * V_aug.H == C\n",
      " |      True\n",
      " |  \n",
      " |  solve(self, rhs, method='GJ')\n",
      " |      Solves linear equation where the unique solution exists.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      rhs : Matrix\n",
      " |          Vector representing the right hand side of the linear equation.\n",
      " |      \n",
      " |      method : string, optional\n",
      " |          If set to ``'GJ'`` or ``'GE'``, the Gauss-Jordan elimination will be\n",
      " |          used, which is implemented in the routine ``gauss_jordan_solve``.\n",
      " |      \n",
      " |          If set to ``'LU'``, ``LUsolve`` routine will be used.\n",
      " |      \n",
      " |          If set to ``'QR'``, ``QRsolve`` routine will be used.\n",
      " |      \n",
      " |          If set to ``'PINV'``, ``pinv_solve`` routine will be used.\n",
      " |      \n",
      " |          It also supports the methods available for special linear systems\n",
      " |      \n",
      " |          For positive definite systems:\n",
      " |      \n",
      " |          If set to ``'CH'``, ``cholesky_solve`` routine will be used.\n",
      " |      \n",
      " |          If set to ``'LDL'``, ``LDLsolve`` routine will be used.\n",
      " |      \n",
      " |          To use a different method and to compute the solution via the\n",
      " |          inverse, use a method defined in the .inv() docstring.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      solutions : Matrix\n",
      " |          Vector representing the solution.\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      ValueError\n",
      " |          If there is not a unique solution then a ``ValueError`` will be\n",
      " |          raised.\n",
      " |      \n",
      " |          If ``M`` is not square, a ``ValueError`` and a different routine\n",
      " |          for solving the system will be suggested.\n",
      " |  \n",
      " |  solve_least_squares(self, rhs, method='CH')\n",
      " |      Return the least-square fit to the data.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      rhs : Matrix\n",
      " |          Vector representing the right hand side of the linear equation.\n",
      " |      \n",
      " |      method : string or boolean, optional\n",
      " |          If set to ``'CH'``, ``cholesky_solve`` routine will be used.\n",
      " |      \n",
      " |          If set to ``'LDL'``, ``LDLsolve`` routine will be used.\n",
      " |      \n",
      " |          If set to ``'QR'``, ``QRsolve`` routine will be used.\n",
      " |      \n",
      " |          If set to ``'PINV'``, ``pinv_solve`` routine will be used.\n",
      " |      \n",
      " |          Otherwise, the conjugate of ``M`` will be used to create a system\n",
      " |          of equations that is passed to ``solve`` along with the hint\n",
      " |          defined by ``method``.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      solutions : Matrix\n",
      " |          Vector representing the solution.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, ones\n",
      " |      >>> A = Matrix([1, 2, 3])\n",
      " |      >>> B = Matrix([2, 3, 4])\n",
      " |      >>> S = Matrix(A.row_join(B))\n",
      " |      >>> S\n",
      " |      Matrix([\n",
      " |      [1, 2],\n",
      " |      [2, 3],\n",
      " |      [3, 4]])\n",
      " |      \n",
      " |      If each line of S represent coefficients of Ax + By\n",
      " |      and x and y are [2, 3] then S*xy is:\n",
      " |      \n",
      " |      >>> r = S*Matrix([2, 3]); r\n",
      " |      Matrix([\n",
      " |      [ 8],\n",
      " |      [13],\n",
      " |      [18]])\n",
      " |      \n",
      " |      But let's add 1 to the middle value and then solve for the\n",
      " |      least-squares value of xy:\n",
      " |      \n",
      " |      >>> xy = S.solve_least_squares(Matrix([8, 14, 18])); xy\n",
      " |      Matrix([\n",
      " |      [ 5/3],\n",
      " |      [10/3]])\n",
      " |      \n",
      " |      The error is given by S*xy - r:\n",
      " |      \n",
      " |      >>> S*xy - r\n",
      " |      Matrix([\n",
      " |      [1/3],\n",
      " |      [1/3],\n",
      " |      [1/3]])\n",
      " |      >>> _.norm().n(2)\n",
      " |      0.58\n",
      " |      \n",
      " |      If a different xy is used, the norm will be higher:\n",
      " |      \n",
      " |      >>> xy += ones(2, 1)/10\n",
      " |      >>> (S*xy - r).norm().n(2)\n",
      " |      1.5\n",
      " |  \n",
      " |  strongly_connected_components(self)\n",
      " |      Returns the list of strongly connected vertices of the graph when\n",
      " |      a square matrix is viewed as a weighted graph.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([\n",
      " |      ...     [44, 0, 0, 0, 43, 0, 45, 0, 0],\n",
      " |      ...     [0, 66, 62, 61, 0, 68, 0, 60, 67],\n",
      " |      ...     [0, 0, 22, 21, 0, 0, 0, 20, 0],\n",
      " |      ...     [0, 0, 12, 11, 0, 0, 0, 10, 0],\n",
      " |      ...     [34, 0, 0, 0, 33, 0, 35, 0, 0],\n",
      " |      ...     [0, 86, 82, 81, 0, 88, 0, 80, 87],\n",
      " |      ...     [54, 0, 0, 0, 53, 0, 55, 0, 0],\n",
      " |      ...     [0, 0, 2, 1, 0, 0, 0, 0, 0],\n",
      " |      ...     [0, 76, 72, 71, 0, 78, 0, 70, 77]])\n",
      " |      >>> A.strongly_connected_components()\n",
      " |      [[0, 4, 6], [2, 3, 7], [1, 5, 8]]\n",
      " |  \n",
      " |  strongly_connected_components_decomposition(self, lower=True)\n",
      " |      Decomposes a square matrix into block triangular form only\n",
      " |      using the permutations.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      The decomposition is in a form of $A = P^{-1} B P$ where $P$ is a\n",
      " |      permutation matrix and $B$ is a block diagonal matrix.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      lower : bool\n",
      " |          Makes $B$ lower block triangular when ``True``.\n",
      " |          Otherwise, makes $B$ upper block triangular.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      P, B : PermutationMatrix, BlockMatrix\n",
      " |          *P* is a permutation matrix for the similarity transform\n",
      " |          as in the explanation. And *B* is the block triangular matrix of\n",
      " |          the result of the permutation.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, pprint\n",
      " |      >>> A = Matrix([\n",
      " |      ...     [44, 0, 0, 0, 43, 0, 45, 0, 0],\n",
      " |      ...     [0, 66, 62, 61, 0, 68, 0, 60, 67],\n",
      " |      ...     [0, 0, 22, 21, 0, 0, 0, 20, 0],\n",
      " |      ...     [0, 0, 12, 11, 0, 0, 0, 10, 0],\n",
      " |      ...     [34, 0, 0, 0, 33, 0, 35, 0, 0],\n",
      " |      ...     [0, 86, 82, 81, 0, 88, 0, 80, 87],\n",
      " |      ...     [54, 0, 0, 0, 53, 0, 55, 0, 0],\n",
      " |      ...     [0, 0, 2, 1, 0, 0, 0, 0, 0],\n",
      " |      ...     [0, 76, 72, 71, 0, 78, 0, 70, 77]])\n",
      " |      \n",
      " |      A lower block triangular decomposition:\n",
      " |      \n",
      " |      >>> P, B = A.strongly_connected_components_decomposition()\n",
      " |      >>> pprint(P)\n",
      " |      PermutationMatrix((8)(1 4 3 2 6)(5 7))\n",
      " |      >>> pprint(B)\n",
      " |      [[44  43  45]   [0  0  0]     [0  0  0]  ]\n",
      " |      [[          ]   [       ]     [       ]  ]\n",
      " |      [[34  33  35]   [0  0  0]     [0  0  0]  ]\n",
      " |      [[          ]   [       ]     [       ]  ]\n",
      " |      [[54  53  55]   [0  0  0]     [0  0  0]  ]\n",
      " |      [                                        ]\n",
      " |      [ [0  0  0]    [22  21  20]   [0  0  0]  ]\n",
      " |      [ [       ]    [          ]   [       ]  ]\n",
      " |      [ [0  0  0]    [12  11  10]   [0  0  0]  ]\n",
      " |      [ [       ]    [          ]   [       ]  ]\n",
      " |      [ [0  0  0]    [2   1   0 ]   [0  0  0]  ]\n",
      " |      [                                        ]\n",
      " |      [ [0  0  0]    [62  61  60]  [66  68  67]]\n",
      " |      [ [       ]    [          ]  [          ]]\n",
      " |      [ [0  0  0]    [82  81  80]  [86  88  87]]\n",
      " |      [ [       ]    [          ]  [          ]]\n",
      " |      [ [0  0  0]    [72  71  70]  [76  78  77]]\n",
      " |      \n",
      " |      >>> P = P.as_explicit()\n",
      " |      >>> B = B.as_explicit()\n",
      " |      >>> P.T * B * P == A\n",
      " |      True\n",
      " |      \n",
      " |      An upper block triangular decomposition:\n",
      " |      \n",
      " |      >>> P, B = A.strongly_connected_components_decomposition(lower=False)\n",
      " |      >>> pprint(P)\n",
      " |      PermutationMatrix((0 1 5 7 4 3 2 8 6))\n",
      " |      >>> pprint(B)\n",
      " |      [[66  68  67]  [62  61  60]   [0  0  0]  ]\n",
      " |      [[          ]  [          ]   [       ]  ]\n",
      " |      [[86  88  87]  [82  81  80]   [0  0  0]  ]\n",
      " |      [[          ]  [          ]   [       ]  ]\n",
      " |      [[76  78  77]  [72  71  70]   [0  0  0]  ]\n",
      " |      [                                        ]\n",
      " |      [ [0  0  0]    [22  21  20]   [0  0  0]  ]\n",
      " |      [ [       ]    [          ]   [       ]  ]\n",
      " |      [ [0  0  0]    [12  11  10]   [0  0  0]  ]\n",
      " |      [ [       ]    [          ]   [       ]  ]\n",
      " |      [ [0  0  0]    [2   1   0 ]   [0  0  0]  ]\n",
      " |      [                                        ]\n",
      " |      [ [0  0  0]     [0  0  0]    [44  43  45]]\n",
      " |      [ [       ]     [       ]    [          ]]\n",
      " |      [ [0  0  0]     [0  0  0]    [34  33  35]]\n",
      " |      [ [       ]     [       ]    [          ]]\n",
      " |      [ [0  0  0]     [0  0  0]    [54  53  55]]\n",
      " |      \n",
      " |      >>> P = P.as_explicit()\n",
      " |      >>> B = B.as_explicit()\n",
      " |      >>> P.T * B * P == A\n",
      " |      True\n",
      " |  \n",
      " |  table(self, printer, rowstart='[', rowend=']', rowsep='\\n', colsep=', ', align='right')\n",
      " |      String form of Matrix as a table.\n",
      " |      \n",
      " |      ``printer`` is the printer to use for on the elements (generally\n",
      " |      something like StrPrinter())\n",
      " |      \n",
      " |      ``rowstart`` is the string used to start each row (by default '[').\n",
      " |      \n",
      " |      ``rowend`` is the string used to end each row (by default ']').\n",
      " |      \n",
      " |      ``rowsep`` is the string used to separate rows (by default a newline).\n",
      " |      \n",
      " |      ``colsep`` is the string used to separate columns (by default ', ').\n",
      " |      \n",
      " |      ``align`` defines how the elements are aligned. Must be one of 'left',\n",
      " |      'right', or 'center'.  You can also use '<', '>', and '^' to mean the\n",
      " |      same thing, respectively.\n",
      " |      \n",
      " |      This is used by the string printer for Matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, StrPrinter\n",
      " |      >>> M = Matrix([[1, 2], [-33, 4]])\n",
      " |      >>> printer = StrPrinter()\n",
      " |      >>> M.table(printer)\n",
      " |      '[  1, 2]\\n[-33, 4]'\n",
      " |      >>> print(M.table(printer))\n",
      " |      [  1, 2]\n",
      " |      [-33, 4]\n",
      " |      >>> print(M.table(printer, rowsep=',\\n'))\n",
      " |      [  1, 2],\n",
      " |      [-33, 4]\n",
      " |      >>> print('[%s]' % M.table(printer, rowsep=',\\n'))\n",
      " |      [[  1, 2],\n",
      " |      [-33, 4]]\n",
      " |      >>> print(M.table(printer, colsep=' '))\n",
      " |      [  1 2]\n",
      " |      [-33 4]\n",
      " |      >>> print(M.table(printer, align='center'))\n",
      " |      [ 1 , 2]\n",
      " |      [-33, 4]\n",
      " |      >>> print(M.table(printer, rowstart='{', rowend='}'))\n",
      " |      {  1, 2}\n",
      " |      {-33, 4}\n",
      " |  \n",
      " |  upper_hessenberg_decomposition(self)\n",
      " |      Converts a matrix into Hessenberg matrix H\n",
      " |      \n",
      " |      Returns 2 matrices H, P s.t.\n",
      " |      $P H P^{T} = A$, where H is an upper hessenberg matrix\n",
      " |      and P is an orthogonal matrix\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([\n",
      " |      ...     [1,2,3],\n",
      " |      ...     [-3,5,6],\n",
      " |      ...     [4,-8,9],\n",
      " |      ... ])\n",
      " |      >>> H, P = A.upper_hessenberg_decomposition()\n",
      " |      >>> H\n",
      " |      Matrix([\n",
      " |      [1,    6/5,    17/5],\n",
      " |      [5, 213/25, -134/25],\n",
      " |      [0, 216/25,  137/25]])\n",
      " |      >>> P\n",
      " |      Matrix([\n",
      " |      [1,    0,   0],\n",
      " |      [0, -3/5, 4/5],\n",
      " |      [0,  4/5, 3/5]])\n",
      " |      >>> P * H * P.H == A\n",
      " |      True\n",
      " |      \n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [#] https://mathworld.wolfram.com/HessenbergDecomposition.html\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.matrices.matrices.MatrixBase:\n",
      " |  \n",
      " |  irregular(ntop, *matrices, **kwargs) from builtins.type\n",
      " |      Return a matrix filled by the given matrices which\n",
      " |      are listed in order of appearance from left to right, top to\n",
      " |      bottom as they first appear in the matrix. They must fill the\n",
      " |      matrix completely.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import ones, Matrix\n",
      " |      >>> Matrix.irregular(3, ones(2,1), ones(3,3)*2, ones(2,2)*3,\n",
      " |      ...   ones(1,1)*4, ones(2,2)*5, ones(1,2)*6, ones(1,2)*7)\n",
      " |      Matrix([\n",
      " |        [1, 2, 2, 2, 3, 3],\n",
      " |        [1, 2, 2, 2, 3, 3],\n",
      " |        [4, 2, 2, 2, 5, 5],\n",
      " |        [6, 6, 7, 7, 5, 5]])\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.matrices.matrices.MatrixBase:\n",
      " |  \n",
      " |  D\n",
      " |      Return Dirac conjugate (if ``self.rows == 4``).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, I, eye\n",
      " |      >>> m = Matrix((0, 1 + I, 2, 3))\n",
      " |      >>> m.D\n",
      " |      Matrix([[0, 1 - I, -2, -3]])\n",
      " |      >>> m = (eye(4) + I*eye(4))\n",
      " |      >>> m[0, 3] = 2\n",
      " |      >>> m.D\n",
      " |      Matrix([\n",
      " |      [1 - I,     0,      0,      0],\n",
      " |      [    0, 1 - I,      0,      0],\n",
      " |      [    0,     0, -1 + I,      0],\n",
      " |      [    2,     0,      0, -1 + I]])\n",
      " |      \n",
      " |      If the matrix does not have 4 rows an AttributeError will be raised\n",
      " |      because this property is only defined for matrices with 4 rows.\n",
      " |      \n",
      " |      >>> Matrix(eye(2)).D\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      AttributeError: Matrix has no attribute D.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.common.MatrixCommon.conjugate: By-element conjugation\n",
      " |      sympy.matrices.common.MatrixCommon.H: Hermite conjugation\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.matrices.matrices.MatrixBase:\n",
      " |  \n",
      " |  __array_priority__ = 11\n",
      " |  \n",
      " |  is_Matrix = True\n",
      " |  \n",
      " |  one = 1\n",
      " |  \n",
      " |  zero = 0\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.matrices.MatrixDeprecated:\n",
      " |  \n",
      " |  berkowitz(self)\n",
      " |  \n",
      " |  berkowitz_charpoly(self, x=_lambda, simplify=<function simplify at 0x7f27788a7940>)\n",
      " |  \n",
      " |  berkowitz_det(self)\n",
      " |      Computes determinant using Berkowitz method.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      det\n",
      " |      berkowitz\n",
      " |  \n",
      " |  berkowitz_eigenvals(self, **flags)\n",
      " |      Computes eigenvalues of a Matrix using Berkowitz method.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      berkowitz\n",
      " |  \n",
      " |  berkowitz_minors(self)\n",
      " |      Computes principal minors using Berkowitz method.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      berkowitz\n",
      " |  \n",
      " |  cofactorMatrix(self, method='berkowitz')\n",
      " |  \n",
      " |  det_LU_decomposition(self)\n",
      " |      Compute matrix determinant using LU decomposition\n",
      " |      \n",
      " |      \n",
      " |      Note that this method fails if the LU decomposition itself\n",
      " |      fails. In particular, if the matrix has no inverse this method\n",
      " |      will fail.\n",
      " |      \n",
      " |      TODO: Implement algorithm for sparse matrices (SFF),\n",
      " |      http://www.eecis.udel.edu/~saunders/papers/sffge/it5.ps.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      \n",
      " |      det\n",
      " |      det_bareiss\n",
      " |      berkowitz_det\n",
      " |  \n",
      " |  det_bareis(self)\n",
      " |  \n",
      " |  jordan_cell(self, eigenval, n)\n",
      " |  \n",
      " |  jordan_cells(self, calc_transformation=True)\n",
      " |  \n",
      " |  minorEntry(self, i, j, method='berkowitz')\n",
      " |  \n",
      " |  minorMatrix(self, i, j)\n",
      " |  \n",
      " |  permuteBkwd(self, perm)\n",
      " |      Permute the rows of the matrix with the given permutation in reverse.\n",
      " |  \n",
      " |  permuteFwd(self, perm)\n",
      " |      Permute the rows of the matrix with the given permutation.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.matrices.MatrixCalculus:\n",
      " |  \n",
      " |  diff(self, *args, **kwargs)\n",
      " |      Calculate the derivative of each element in the matrix.\n",
      " |      ``args`` will be passed to the ``integrate`` function.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> M = Matrix([[x, y], [1, 0]])\n",
      " |      >>> M.diff(x)\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 0]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      integrate\n",
      " |      limit\n",
      " |  \n",
      " |  integrate(self, *args, **kwargs)\n",
      " |      Integrate each element of the matrix.  ``args`` will\n",
      " |      be passed to the ``integrate`` function.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> M = Matrix([[x, y], [1, 0]])\n",
      " |      >>> M.integrate((x, ))\n",
      " |      Matrix([\n",
      " |      [x**2/2, x*y],\n",
      " |      [     x,   0]])\n",
      " |      >>> M.integrate((x, 0, 2))\n",
      " |      Matrix([\n",
      " |      [2, 2*y],\n",
      " |      [2,   0]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      limit\n",
      " |      diff\n",
      " |  \n",
      " |  jacobian(self, X)\n",
      " |      Calculates the Jacobian matrix (derivative of a vector-valued function).\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      ``self`` : vector of expressions representing functions f_i(x_1, ..., x_n).\n",
      " |      X : set of x_i's in order, it can be a list or a Matrix\n",
      " |      \n",
      " |      Both ``self`` and X can be a row or a column matrix in any order\n",
      " |      (i.e., jacobian() should always work).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin, cos, Matrix\n",
      " |      >>> from sympy.abc import rho, phi\n",
      " |      >>> X = Matrix([rho*cos(phi), rho*sin(phi), rho**2])\n",
      " |      >>> Y = Matrix([rho, phi])\n",
      " |      >>> X.jacobian(Y)\n",
      " |      Matrix([\n",
      " |      [cos(phi), -rho*sin(phi)],\n",
      " |      [sin(phi),  rho*cos(phi)],\n",
      " |      [   2*rho,             0]])\n",
      " |      >>> X = Matrix([rho*cos(phi), rho*sin(phi)])\n",
      " |      >>> X.jacobian(Y)\n",
      " |      Matrix([\n",
      " |      [cos(phi), -rho*sin(phi)],\n",
      " |      [sin(phi),  rho*cos(phi)]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      hessian\n",
      " |      wronskian\n",
      " |  \n",
      " |  limit(self, *args)\n",
      " |      Calculate the limit of each element in the matrix.\n",
      " |      ``args`` will be passed to the ``limit`` function.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> M = Matrix([[x, y], [1, 0]])\n",
      " |      >>> M.limit(x, 2)\n",
      " |      Matrix([\n",
      " |      [2, y],\n",
      " |      [1, 0]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      integrate\n",
      " |      diff\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.matrices.MatrixEigen:\n",
      " |  \n",
      " |  bidiagonal_decomposition(self, upper=True)\n",
      " |      Returns $(U,B,V.H)$ for\n",
      " |      \n",
      " |      $$A = UBV^{H}$$\n",
      " |      \n",
      " |      where $A$ is the input matrix, and $B$ is its Bidiagonalized form\n",
      " |      \n",
      " |      Note: Bidiagonal Computation can hang for symbolic matrices.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      upper : bool. Whether to do upper bidiagnalization or lower.\n",
      " |                  True for upper and False for lower.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] Algorithm 5.4.2, Matrix computations by Golub and Van Loan, 4th edition\n",
      " |      .. [2] Complex Matrix Bidiagonalization, https://github.com/vslobody/Householder-Bidiagonalization\n",
      " |  \n",
      " |  bidiagonalize(self, upper=True)\n",
      " |      Returns $B$, the Bidiagonalized form of the input matrix.\n",
      " |      \n",
      " |      Note: Bidiagonal Computation can hang for symbolic matrices.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      upper : bool. Whether to do upper bidiagnalization or lower.\n",
      " |                  True for upper and False for lower.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] Algorithm 5.4.2, Matrix computations by Golub and Van Loan, 4th edition\n",
      " |      .. [2] Complex Matrix Bidiagonalization : https://github.com/vslobody/Householder-Bidiagonalization\n",
      " |  \n",
      " |  diagonalize(self, reals_only=False, sort=False, normalize=False)\n",
      " |      Return (P, D), where D is diagonal and\n",
      " |      \n",
      " |          D = P^-1 * M * P\n",
      " |      \n",
      " |      where M is current matrix.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      reals_only : bool. Whether to throw an error if complex numbers are need\n",
      " |                      to diagonalize. (Default: False)\n",
      " |      \n",
      " |      sort : bool. Sort the eigenvalues along the diagonal. (Default: False)\n",
      " |      \n",
      " |      normalize : bool. If True, normalize the columns of P. (Default: False)\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix(3, 3, [1, 2, 0, 0, 3, 0, 2, -4, 2])\n",
      " |      >>> M\n",
      " |      Matrix([\n",
      " |      [1,  2, 0],\n",
      " |      [0,  3, 0],\n",
      " |      [2, -4, 2]])\n",
      " |      >>> (P, D) = M.diagonalize()\n",
      " |      >>> D\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 2, 0],\n",
      " |      [0, 0, 3]])\n",
      " |      >>> P\n",
      " |      Matrix([\n",
      " |      [-1, 0, -1],\n",
      " |      [ 0, 0, -1],\n",
      " |      [ 2, 1,  2]])\n",
      " |      >>> P.inv() * M * P\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 2, 0],\n",
      " |      [0, 0, 3]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      is_diagonal\n",
      " |      is_diagonalizable\n",
      " |  \n",
      " |  eigenvals(self, error_when_incomplete=True, **flags)\n",
      " |      Compute eigenvalues of the matrix.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      error_when_incomplete : bool, optional\n",
      " |          If it is set to ``True``, it will raise an error if not all\n",
      " |          eigenvalues are computed. This is caused by ``roots`` not returning\n",
      " |          a full list of eigenvalues.\n",
      " |      \n",
      " |      simplify : bool or function, optional\n",
      " |          If it is set to ``True``, it attempts to return the most\n",
      " |          simplified form of expressions returned by applying default\n",
      " |          simplification method in every routine.\n",
      " |      \n",
      " |          If it is set to ``False``, it will skip simplification in this\n",
      " |          particular routine to save computation resources.\n",
      " |      \n",
      " |          If a function is passed to, it will attempt to apply\n",
      " |          the particular function as simplification method.\n",
      " |      \n",
      " |      rational : bool, optional\n",
      " |          If it is set to ``True``, every floating point numbers would be\n",
      " |          replaced with rationals before computation. It can solve some\n",
      " |          issues of ``roots`` routine not working well with floats.\n",
      " |      \n",
      " |      multiple : bool, optional\n",
      " |          If it is set to ``True``, the result will be in the form of a\n",
      " |          list.\n",
      " |      \n",
      " |          If it is set to ``False``, the result will be in the form of a\n",
      " |          dictionary.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      eigs : list or dict\n",
      " |          Eigenvalues of a matrix. The return format would be specified by\n",
      " |          the key ``multiple``.\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      MatrixError\n",
      " |          If not enough roots had got computed.\n",
      " |      \n",
      " |      NonSquareMatrixError\n",
      " |          If attempted to compute eigenvalues from a non-square matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix(3, 3, [0, 1, 1, 1, 0, 0, 1, 1, 1])\n",
      " |      >>> M.eigenvals()\n",
      " |      {-1: 1, 0: 1, 2: 1}\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      MatrixDeterminant.charpoly\n",
      " |      eigenvects\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Eigenvalues of a matrix $A$ can be computed by solving a matrix\n",
      " |      equation $\\det(A - \\lambda I) = 0$\n",
      " |      \n",
      " |      It's not always possible to return radical solutions for\n",
      " |      eigenvalues for matrices larger than $4, 4$ shape due to\n",
      " |      Abel-Ruffini theorem.\n",
      " |      \n",
      " |      If there is no radical solution is found for the eigenvalue,\n",
      " |      it may return eigenvalues in the form of\n",
      " |      :class:`sympy.polys.rootoftools.ComplexRootOf`.\n",
      " |  \n",
      " |  eigenvects(self, error_when_incomplete=True, iszerofunc=<function _iszero at 0x7f27787b60d0>, **flags)\n",
      " |      Compute eigenvectors of the matrix.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      error_when_incomplete : bool, optional\n",
      " |          Raise an error when not all eigenvalues are computed. This is\n",
      " |          caused by ``roots`` not returning a full list of eigenvalues.\n",
      " |      \n",
      " |      iszerofunc : function, optional\n",
      " |          Specifies a zero testing function to be used in ``rref``.\n",
      " |      \n",
      " |          Default value is ``_iszero``, which uses SymPy's naive and fast\n",
      " |          default assumption handler.\n",
      " |      \n",
      " |          It can also accept any user-specified zero testing function, if it\n",
      " |          is formatted as a function which accepts a single symbolic argument\n",
      " |          and returns ``True`` if it is tested as zero and ``False`` if it\n",
      " |          is tested as non-zero, and ``None`` if it is undecidable.\n",
      " |      \n",
      " |      simplify : bool or function, optional\n",
      " |          If ``True``, ``as_content_primitive()`` will be used to tidy up\n",
      " |          normalization artifacts.\n",
      " |      \n",
      " |          It will also be used by the ``nullspace`` routine.\n",
      " |      \n",
      " |      chop : bool or positive number, optional\n",
      " |          If the matrix contains any Floats, they will be changed to Rationals\n",
      " |          for computation purposes, but the answers will be returned after\n",
      " |          being evaluated with evalf. The ``chop`` flag is passed to ``evalf``.\n",
      " |          When ``chop=True`` a default precision will be used; a number will\n",
      " |          be interpreted as the desired level of precision.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      ret : [(eigenval, multiplicity, eigenspace), ...]\n",
      " |          A ragged list containing tuples of data obtained by ``eigenvals``\n",
      " |          and ``nullspace``.\n",
      " |      \n",
      " |          ``eigenspace`` is a list containing the ``eigenvector`` for each\n",
      " |          eigenvalue.\n",
      " |      \n",
      " |          ``eigenvector`` is a vector in the form of a ``Matrix``. e.g.\n",
      " |          a vector of length 3 is returned as ``Matrix([a_1, a_2, a_3])``.\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      NotImplementedError\n",
      " |          If failed to compute nullspace.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix(3, 3, [0, 1, 1, 1, 0, 0, 1, 1, 1])\n",
      " |      >>> M.eigenvects()\n",
      " |      [(-1, 1, [Matrix([\n",
      " |      [-1],\n",
      " |      [ 1],\n",
      " |      [ 0]])]), (0, 1, [Matrix([\n",
      " |      [ 0],\n",
      " |      [-1],\n",
      " |      [ 1]])]), (2, 1, [Matrix([\n",
      " |      [2/3],\n",
      " |      [1/3],\n",
      " |      [  1]])])]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      eigenvals\n",
      " |      MatrixSubspaces.nullspace\n",
      " |  \n",
      " |  is_diagonalizable(self, reals_only=False, **kwargs)\n",
      " |      Returns ``True`` if a matrix is diagonalizable.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      reals_only : bool, optional\n",
      " |          If ``True``, it tests whether the matrix can be diagonalized\n",
      " |          to contain only real numbers on the diagonal.\n",
      " |      \n",
      " |      \n",
      " |          If ``False``, it tests whether the matrix can be diagonalized\n",
      " |          at all, even with numbers that may not be real.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      Example of a diagonalizable matrix:\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 2, 0], [0, 3, 0], [2, -4, 2]])\n",
      " |      >>> M.is_diagonalizable()\n",
      " |      True\n",
      " |      \n",
      " |      Example of a non-diagonalizable matrix:\n",
      " |      \n",
      " |      >>> M = Matrix([[0, 1], [0, 0]])\n",
      " |      >>> M.is_diagonalizable()\n",
      " |      False\n",
      " |      \n",
      " |      Example of a matrix that is diagonalized in terms of non-real entries:\n",
      " |      \n",
      " |      >>> M = Matrix([[0, 1], [-1, 0]])\n",
      " |      >>> M.is_diagonalizable(reals_only=False)\n",
      " |      True\n",
      " |      >>> M.is_diagonalizable(reals_only=True)\n",
      " |      False\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      is_diagonal\n",
      " |      diagonalize\n",
      " |  \n",
      " |  jordan_form(self, calc_transform=True, **kwargs)\n",
      " |      Return $(P, J)$ where $J$ is a Jordan block\n",
      " |      matrix and $P$ is a matrix such that $M = P J P^{-1}$\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      calc_transform : bool\n",
      " |          If ``False``, then only $J$ is returned.\n",
      " |      \n",
      " |      chop : bool\n",
      " |          All matrices are converted to exact types when computing\n",
      " |          eigenvalues and eigenvectors.  As a result, there may be\n",
      " |          approximation errors.  If ``chop==True``, these errors\n",
      " |          will be truncated.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[ 6,  5, -2, -3], [-3, -1,  3,  3], [ 2,  1, -2, -3], [-1,  1,  5,  5]])\n",
      " |      >>> P, J = M.jordan_form()\n",
      " |      >>> J\n",
      " |      Matrix([\n",
      " |      [2, 1, 0, 0],\n",
      " |      [0, 2, 0, 0],\n",
      " |      [0, 0, 2, 1],\n",
      " |      [0, 0, 0, 2]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      jordan_block\n",
      " |  \n",
      " |  left_eigenvects(self, **flags)\n",
      " |      Returns left eigenvectors and eigenvalues.\n",
      " |      \n",
      " |      This function returns the list of triples (eigenval, multiplicity,\n",
      " |      basis) for the left eigenvectors. Options are the same as for\n",
      " |      eigenvects(), i.e. the ``**flags`` arguments gets passed directly to\n",
      " |      eigenvects().\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[0, 1, 1], [1, 0, 0], [1, 1, 1]])\n",
      " |      >>> M.eigenvects()\n",
      " |      [(-1, 1, [Matrix([\n",
      " |      [-1],\n",
      " |      [ 1],\n",
      " |      [ 0]])]), (0, 1, [Matrix([\n",
      " |      [ 0],\n",
      " |      [-1],\n",
      " |      [ 1]])]), (2, 1, [Matrix([\n",
      " |      [2/3],\n",
      " |      [1/3],\n",
      " |      [  1]])])]\n",
      " |      >>> M.left_eigenvects()\n",
      " |      [(-1, 1, [Matrix([[-2, 1, 1]])]), (0, 1, [Matrix([[-1, -1, 1]])]), (2,\n",
      " |      1, [Matrix([[1, 1, 1]])])]\n",
      " |  \n",
      " |  singular_values(self)\n",
      " |      Compute the singular values of a Matrix\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, Symbol\n",
      " |      >>> x = Symbol('x', real=True)\n",
      " |      >>> M = Matrix([[0, 1, 0], [0, x, 0], [-1, 0, 0]])\n",
      " |      >>> M.singular_values()\n",
      " |      [sqrt(x**2 + 1), 1, 0]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      condition_number\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.matrices.matrices.MatrixEigen:\n",
      " |  \n",
      " |  is_indefinite\n",
      " |      Finds out the definiteness of a matrix.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A square real matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $x^T A x > 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A positive semidefinite matrix if $x^T A x \\geq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative definite matrix if $x^T A x < 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative semidefinite matrix if $x^T A x \\leq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero real vectors\n",
      " |        $x, y$ with $x^T A x > 0 > y^T A y$.\n",
      " |      \n",
      " |      A square complex matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $\\text{re}(x^H A x) > 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A positive semidefinite matrix if $\\text{re}(x^H A x) \\geq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative definite matrix if $\\text{re}(x^H A x) < 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative semidefinite matrix if $\\text{re}(x^H A x) \\leq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero complex vectors\n",
      " |        $x, y$ with $\\text{re}(x^H A x) > 0 > \\text{re}(y^H A y)$.\n",
      " |      \n",
      " |      A matrix need not be symmetric or hermitian to be positive definite.\n",
      " |      \n",
      " |      - A real non-symmetric matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^T}{2}$ is positive definite.\n",
      " |      - A complex non-hermitian matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^H}{2}$ is positive definite.\n",
      " |      \n",
      " |      And this extension can apply for all the definitions above.\n",
      " |      \n",
      " |      However, for complex cases, you can restrict the definition of\n",
      " |      $\\text{re}(x^H A x) > 0$ to $x^H A x > 0$ and require the matrix\n",
      " |      to be hermitian.\n",
      " |      But we do not present this restriction for computation because you\n",
      " |      can check ``M.is_hermitian`` independently with this and use\n",
      " |      the same procedure.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      An example of symmetric positive definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: reset\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> from sympy import Matrix, symbols\n",
      " |          >>> from sympy.plotting import plot3d\n",
      " |          >>> a, b = symbols('a b')\n",
      " |          >>> x = Matrix([a, b])\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 0], [0, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric positive semidefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, -1], [-1, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          False\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric negative definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[-1, 0], [0, -1]])\n",
      " |          >>> A.is_negative_definite\n",
      " |          True\n",
      " |          >>> A.is_negative_semidefinite\n",
      " |          True\n",
      " |          >>> A.is_indefinite\n",
      " |          False\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric indefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [2, -1]])\n",
      " |          >>> A.is_indefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of non-symmetric positive definite matrix.\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [-2, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Although some people trivialize the definition of positive definite\n",
      " |      matrices only for symmetric or hermitian matrices, this restriction\n",
      " |      is not correct because it does not classify all instances of\n",
      " |      positive definite matrices from the definition $x^T A x > 0$ or\n",
      " |      $\\text{re}(x^H A x) > 0$.\n",
      " |      \n",
      " |      For instance, ``Matrix([[1, 2], [-2, 1]])`` presented in\n",
      " |      the example above is an example of real positive definite matrix\n",
      " |      that is not symmetric.\n",
      " |      \n",
      " |      However, since the following formula holds true;\n",
      " |      \n",
      " |      .. math::\n",
      " |          \\text{re}(x^H A x) > 0 \\iff\n",
      " |          \\text{re}(x^H \\frac{A + A^H}{2} x) > 0\n",
      " |      \n",
      " |      We can classify all positive definite matrices that may or may not\n",
      " |      be symmetric or hermitian by transforming the matrix to\n",
      " |      $\\frac{A + A^T}{2}$ or $\\frac{A + A^H}{2}$\n",
      " |      (which is guaranteed to be always real symmetric or complex\n",
      " |      hermitian) and we can defer most of the studies to symmetric or\n",
      " |      hermitian positive definite matrices.\n",
      " |      \n",
      " |      But it is a different problem for the existance of Cholesky\n",
      " |      decomposition. Because even though a non symmetric or a non\n",
      " |      hermitian matrix can be positive definite, Cholesky or LDL\n",
      " |      decomposition does not exist because the decompositions require the\n",
      " |      matrix to be symmetric or hermitian.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Definiteness_of_a_matrix#Eigenvalues\n",
      " |      \n",
      " |      .. [2] http://mathworld.wolfram.com/PositiveDefiniteMatrix.html\n",
      " |      \n",
      " |      .. [3] Johnson, C. R. \"Positive Definite Matrices.\" Amer.\n",
      " |          Math. Monthly 77, 259-264 1970.\n",
      " |  \n",
      " |  is_negative_definite\n",
      " |      Finds out the definiteness of a matrix.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A square real matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $x^T A x > 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A positive semidefinite matrix if $x^T A x \\geq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative definite matrix if $x^T A x < 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative semidefinite matrix if $x^T A x \\leq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero real vectors\n",
      " |        $x, y$ with $x^T A x > 0 > y^T A y$.\n",
      " |      \n",
      " |      A square complex matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $\\text{re}(x^H A x) > 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A positive semidefinite matrix if $\\text{re}(x^H A x) \\geq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative definite matrix if $\\text{re}(x^H A x) < 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative semidefinite matrix if $\\text{re}(x^H A x) \\leq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero complex vectors\n",
      " |        $x, y$ with $\\text{re}(x^H A x) > 0 > \\text{re}(y^H A y)$.\n",
      " |      \n",
      " |      A matrix need not be symmetric or hermitian to be positive definite.\n",
      " |      \n",
      " |      - A real non-symmetric matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^T}{2}$ is positive definite.\n",
      " |      - A complex non-hermitian matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^H}{2}$ is positive definite.\n",
      " |      \n",
      " |      And this extension can apply for all the definitions above.\n",
      " |      \n",
      " |      However, for complex cases, you can restrict the definition of\n",
      " |      $\\text{re}(x^H A x) > 0$ to $x^H A x > 0$ and require the matrix\n",
      " |      to be hermitian.\n",
      " |      But we do not present this restriction for computation because you\n",
      " |      can check ``M.is_hermitian`` independently with this and use\n",
      " |      the same procedure.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      An example of symmetric positive definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: reset\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> from sympy import Matrix, symbols\n",
      " |          >>> from sympy.plotting import plot3d\n",
      " |          >>> a, b = symbols('a b')\n",
      " |          >>> x = Matrix([a, b])\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 0], [0, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric positive semidefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, -1], [-1, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          False\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric negative definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[-1, 0], [0, -1]])\n",
      " |          >>> A.is_negative_definite\n",
      " |          True\n",
      " |          >>> A.is_negative_semidefinite\n",
      " |          True\n",
      " |          >>> A.is_indefinite\n",
      " |          False\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric indefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [2, -1]])\n",
      " |          >>> A.is_indefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of non-symmetric positive definite matrix.\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [-2, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Although some people trivialize the definition of positive definite\n",
      " |      matrices only for symmetric or hermitian matrices, this restriction\n",
      " |      is not correct because it does not classify all instances of\n",
      " |      positive definite matrices from the definition $x^T A x > 0$ or\n",
      " |      $\\text{re}(x^H A x) > 0$.\n",
      " |      \n",
      " |      For instance, ``Matrix([[1, 2], [-2, 1]])`` presented in\n",
      " |      the example above is an example of real positive definite matrix\n",
      " |      that is not symmetric.\n",
      " |      \n",
      " |      However, since the following formula holds true;\n",
      " |      \n",
      " |      .. math::\n",
      " |          \\text{re}(x^H A x) > 0 \\iff\n",
      " |          \\text{re}(x^H \\frac{A + A^H}{2} x) > 0\n",
      " |      \n",
      " |      We can classify all positive definite matrices that may or may not\n",
      " |      be symmetric or hermitian by transforming the matrix to\n",
      " |      $\\frac{A + A^T}{2}$ or $\\frac{A + A^H}{2}$\n",
      " |      (which is guaranteed to be always real symmetric or complex\n",
      " |      hermitian) and we can defer most of the studies to symmetric or\n",
      " |      hermitian positive definite matrices.\n",
      " |      \n",
      " |      But it is a different problem for the existance of Cholesky\n",
      " |      decomposition. Because even though a non symmetric or a non\n",
      " |      hermitian matrix can be positive definite, Cholesky or LDL\n",
      " |      decomposition does not exist because the decompositions require the\n",
      " |      matrix to be symmetric or hermitian.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Definiteness_of_a_matrix#Eigenvalues\n",
      " |      \n",
      " |      .. [2] http://mathworld.wolfram.com/PositiveDefiniteMatrix.html\n",
      " |      \n",
      " |      .. [3] Johnson, C. R. \"Positive Definite Matrices.\" Amer.\n",
      " |          Math. Monthly 77, 259-264 1970.\n",
      " |  \n",
      " |  is_negative_semidefinite\n",
      " |      Finds out the definiteness of a matrix.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A square real matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $x^T A x > 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A positive semidefinite matrix if $x^T A x \\geq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative definite matrix if $x^T A x < 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative semidefinite matrix if $x^T A x \\leq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero real vectors\n",
      " |        $x, y$ with $x^T A x > 0 > y^T A y$.\n",
      " |      \n",
      " |      A square complex matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $\\text{re}(x^H A x) > 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A positive semidefinite matrix if $\\text{re}(x^H A x) \\geq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative definite matrix if $\\text{re}(x^H A x) < 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative semidefinite matrix if $\\text{re}(x^H A x) \\leq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero complex vectors\n",
      " |        $x, y$ with $\\text{re}(x^H A x) > 0 > \\text{re}(y^H A y)$.\n",
      " |      \n",
      " |      A matrix need not be symmetric or hermitian to be positive definite.\n",
      " |      \n",
      " |      - A real non-symmetric matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^T}{2}$ is positive definite.\n",
      " |      - A complex non-hermitian matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^H}{2}$ is positive definite.\n",
      " |      \n",
      " |      And this extension can apply for all the definitions above.\n",
      " |      \n",
      " |      However, for complex cases, you can restrict the definition of\n",
      " |      $\\text{re}(x^H A x) > 0$ to $x^H A x > 0$ and require the matrix\n",
      " |      to be hermitian.\n",
      " |      But we do not present this restriction for computation because you\n",
      " |      can check ``M.is_hermitian`` independently with this and use\n",
      " |      the same procedure.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      An example of symmetric positive definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: reset\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> from sympy import Matrix, symbols\n",
      " |          >>> from sympy.plotting import plot3d\n",
      " |          >>> a, b = symbols('a b')\n",
      " |          >>> x = Matrix([a, b])\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 0], [0, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric positive semidefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, -1], [-1, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          False\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric negative definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[-1, 0], [0, -1]])\n",
      " |          >>> A.is_negative_definite\n",
      " |          True\n",
      " |          >>> A.is_negative_semidefinite\n",
      " |          True\n",
      " |          >>> A.is_indefinite\n",
      " |          False\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric indefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [2, -1]])\n",
      " |          >>> A.is_indefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of non-symmetric positive definite matrix.\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [-2, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Although some people trivialize the definition of positive definite\n",
      " |      matrices only for symmetric or hermitian matrices, this restriction\n",
      " |      is not correct because it does not classify all instances of\n",
      " |      positive definite matrices from the definition $x^T A x > 0$ or\n",
      " |      $\\text{re}(x^H A x) > 0$.\n",
      " |      \n",
      " |      For instance, ``Matrix([[1, 2], [-2, 1]])`` presented in\n",
      " |      the example above is an example of real positive definite matrix\n",
      " |      that is not symmetric.\n",
      " |      \n",
      " |      However, since the following formula holds true;\n",
      " |      \n",
      " |      .. math::\n",
      " |          \\text{re}(x^H A x) > 0 \\iff\n",
      " |          \\text{re}(x^H \\frac{A + A^H}{2} x) > 0\n",
      " |      \n",
      " |      We can classify all positive definite matrices that may or may not\n",
      " |      be symmetric or hermitian by transforming the matrix to\n",
      " |      $\\frac{A + A^T}{2}$ or $\\frac{A + A^H}{2}$\n",
      " |      (which is guaranteed to be always real symmetric or complex\n",
      " |      hermitian) and we can defer most of the studies to symmetric or\n",
      " |      hermitian positive definite matrices.\n",
      " |      \n",
      " |      But it is a different problem for the existance of Cholesky\n",
      " |      decomposition. Because even though a non symmetric or a non\n",
      " |      hermitian matrix can be positive definite, Cholesky or LDL\n",
      " |      decomposition does not exist because the decompositions require the\n",
      " |      matrix to be symmetric or hermitian.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Definiteness_of_a_matrix#Eigenvalues\n",
      " |      \n",
      " |      .. [2] http://mathworld.wolfram.com/PositiveDefiniteMatrix.html\n",
      " |      \n",
      " |      .. [3] Johnson, C. R. \"Positive Definite Matrices.\" Amer.\n",
      " |          Math. Monthly 77, 259-264 1970.\n",
      " |  \n",
      " |  is_positive_definite\n",
      " |      Finds out the definiteness of a matrix.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A square real matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $x^T A x > 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A positive semidefinite matrix if $x^T A x \\geq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative definite matrix if $x^T A x < 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative semidefinite matrix if $x^T A x \\leq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero real vectors\n",
      " |        $x, y$ with $x^T A x > 0 > y^T A y$.\n",
      " |      \n",
      " |      A square complex matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $\\text{re}(x^H A x) > 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A positive semidefinite matrix if $\\text{re}(x^H A x) \\geq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative definite matrix if $\\text{re}(x^H A x) < 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative semidefinite matrix if $\\text{re}(x^H A x) \\leq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero complex vectors\n",
      " |        $x, y$ with $\\text{re}(x^H A x) > 0 > \\text{re}(y^H A y)$.\n",
      " |      \n",
      " |      A matrix need not be symmetric or hermitian to be positive definite.\n",
      " |      \n",
      " |      - A real non-symmetric matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^T}{2}$ is positive definite.\n",
      " |      - A complex non-hermitian matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^H}{2}$ is positive definite.\n",
      " |      \n",
      " |      And this extension can apply for all the definitions above.\n",
      " |      \n",
      " |      However, for complex cases, you can restrict the definition of\n",
      " |      $\\text{re}(x^H A x) > 0$ to $x^H A x > 0$ and require the matrix\n",
      " |      to be hermitian.\n",
      " |      But we do not present this restriction for computation because you\n",
      " |      can check ``M.is_hermitian`` independently with this and use\n",
      " |      the same procedure.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      An example of symmetric positive definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: reset\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> from sympy import Matrix, symbols\n",
      " |          >>> from sympy.plotting import plot3d\n",
      " |          >>> a, b = symbols('a b')\n",
      " |          >>> x = Matrix([a, b])\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 0], [0, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric positive semidefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, -1], [-1, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          False\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric negative definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[-1, 0], [0, -1]])\n",
      " |          >>> A.is_negative_definite\n",
      " |          True\n",
      " |          >>> A.is_negative_semidefinite\n",
      " |          True\n",
      " |          >>> A.is_indefinite\n",
      " |          False\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric indefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [2, -1]])\n",
      " |          >>> A.is_indefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of non-symmetric positive definite matrix.\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [-2, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Although some people trivialize the definition of positive definite\n",
      " |      matrices only for symmetric or hermitian matrices, this restriction\n",
      " |      is not correct because it does not classify all instances of\n",
      " |      positive definite matrices from the definition $x^T A x > 0$ or\n",
      " |      $\\text{re}(x^H A x) > 0$.\n",
      " |      \n",
      " |      For instance, ``Matrix([[1, 2], [-2, 1]])`` presented in\n",
      " |      the example above is an example of real positive definite matrix\n",
      " |      that is not symmetric.\n",
      " |      \n",
      " |      However, since the following formula holds true;\n",
      " |      \n",
      " |      .. math::\n",
      " |          \\text{re}(x^H A x) > 0 \\iff\n",
      " |          \\text{re}(x^H \\frac{A + A^H}{2} x) > 0\n",
      " |      \n",
      " |      We can classify all positive definite matrices that may or may not\n",
      " |      be symmetric or hermitian by transforming the matrix to\n",
      " |      $\\frac{A + A^T}{2}$ or $\\frac{A + A^H}{2}$\n",
      " |      (which is guaranteed to be always real symmetric or complex\n",
      " |      hermitian) and we can defer most of the studies to symmetric or\n",
      " |      hermitian positive definite matrices.\n",
      " |      \n",
      " |      But it is a different problem for the existance of Cholesky\n",
      " |      decomposition. Because even though a non symmetric or a non\n",
      " |      hermitian matrix can be positive definite, Cholesky or LDL\n",
      " |      decomposition does not exist because the decompositions require the\n",
      " |      matrix to be symmetric or hermitian.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Definiteness_of_a_matrix#Eigenvalues\n",
      " |      \n",
      " |      .. [2] http://mathworld.wolfram.com/PositiveDefiniteMatrix.html\n",
      " |      \n",
      " |      .. [3] Johnson, C. R. \"Positive Definite Matrices.\" Amer.\n",
      " |          Math. Monthly 77, 259-264 1970.\n",
      " |  \n",
      " |  is_positive_semidefinite\n",
      " |      Finds out the definiteness of a matrix.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A square real matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $x^T A x > 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A positive semidefinite matrix if $x^T A x \\geq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative definite matrix if $x^T A x < 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - A negative semidefinite matrix if $x^T A x \\leq 0$\n",
      " |        for all non-zero real vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero real vectors\n",
      " |        $x, y$ with $x^T A x > 0 > y^T A y$.\n",
      " |      \n",
      " |      A square complex matrix $A$ is:\n",
      " |      \n",
      " |      - A positive definite matrix if $\\text{re}(x^H A x) > 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A positive semidefinite matrix if $\\text{re}(x^H A x) \\geq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative definite matrix if $\\text{re}(x^H A x) < 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - A negative semidefinite matrix if $\\text{re}(x^H A x) \\leq 0$\n",
      " |        for all non-zero complex vectors $x$.\n",
      " |      - An indefinite matrix if there exists non-zero complex vectors\n",
      " |        $x, y$ with $\\text{re}(x^H A x) > 0 > \\text{re}(y^H A y)$.\n",
      " |      \n",
      " |      A matrix need not be symmetric or hermitian to be positive definite.\n",
      " |      \n",
      " |      - A real non-symmetric matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^T}{2}$ is positive definite.\n",
      " |      - A complex non-hermitian matrix is positive definite if and only if\n",
      " |        $\\frac{A + A^H}{2}$ is positive definite.\n",
      " |      \n",
      " |      And this extension can apply for all the definitions above.\n",
      " |      \n",
      " |      However, for complex cases, you can restrict the definition of\n",
      " |      $\\text{re}(x^H A x) > 0$ to $x^H A x > 0$ and require the matrix\n",
      " |      to be hermitian.\n",
      " |      But we do not present this restriction for computation because you\n",
      " |      can check ``M.is_hermitian`` independently with this and use\n",
      " |      the same procedure.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      An example of symmetric positive definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: reset\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> from sympy import Matrix, symbols\n",
      " |          >>> from sympy.plotting import plot3d\n",
      " |          >>> a, b = symbols('a b')\n",
      " |          >>> x = Matrix([a, b])\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 0], [0, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric positive semidefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, -1], [-1, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          False\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric negative definite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[-1, 0], [0, -1]])\n",
      " |          >>> A.is_negative_definite\n",
      " |          True\n",
      " |          >>> A.is_negative_semidefinite\n",
      " |          True\n",
      " |          >>> A.is_indefinite\n",
      " |          False\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of symmetric indefinite matrix:\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [2, -1]])\n",
      " |          >>> A.is_indefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      An example of non-symmetric positive definite matrix.\n",
      " |      \n",
      " |      .. plot::\n",
      " |          :context: close-figs\n",
      " |          :format: doctest\n",
      " |          :include-source: True\n",
      " |      \n",
      " |          >>> A = Matrix([[1, 2], [-2, 1]])\n",
      " |          >>> A.is_positive_definite\n",
      " |          True\n",
      " |          >>> A.is_positive_semidefinite\n",
      " |          True\n",
      " |      \n",
      " |          >>> p = plot3d((x.T*A*x)[0, 0], (a, -1, 1), (b, -1, 1))\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Although some people trivialize the definition of positive definite\n",
      " |      matrices only for symmetric or hermitian matrices, this restriction\n",
      " |      is not correct because it does not classify all instances of\n",
      " |      positive definite matrices from the definition $x^T A x > 0$ or\n",
      " |      $\\text{re}(x^H A x) > 0$.\n",
      " |      \n",
      " |      For instance, ``Matrix([[1, 2], [-2, 1]])`` presented in\n",
      " |      the example above is an example of real positive definite matrix\n",
      " |      that is not symmetric.\n",
      " |      \n",
      " |      However, since the following formula holds true;\n",
      " |      \n",
      " |      .. math::\n",
      " |          \\text{re}(x^H A x) > 0 \\iff\n",
      " |          \\text{re}(x^H \\frac{A + A^H}{2} x) > 0\n",
      " |      \n",
      " |      We can classify all positive definite matrices that may or may not\n",
      " |      be symmetric or hermitian by transforming the matrix to\n",
      " |      $\\frac{A + A^T}{2}$ or $\\frac{A + A^H}{2}$\n",
      " |      (which is guaranteed to be always real symmetric or complex\n",
      " |      hermitian) and we can defer most of the studies to symmetric or\n",
      " |      hermitian positive definite matrices.\n",
      " |      \n",
      " |      But it is a different problem for the existance of Cholesky\n",
      " |      decomposition. Because even though a non symmetric or a non\n",
      " |      hermitian matrix can be positive definite, Cholesky or LDL\n",
      " |      decomposition does not exist because the decompositions require the\n",
      " |      matrix to be symmetric or hermitian.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Definiteness_of_a_matrix#Eigenvalues\n",
      " |      \n",
      " |      .. [2] http://mathworld.wolfram.com/PositiveDefiniteMatrix.html\n",
      " |      \n",
      " |      .. [3] Johnson, C. R. \"Positive Definite Matrices.\" Amer.\n",
      " |          Math. Monthly 77, 259-264 1970.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.matrices.MatrixSubspaces:\n",
      " |  \n",
      " |  columnspace(self, simplify=False)\n",
      " |      Returns a list of vectors (Matrix objects) that span columnspace of ``M``\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix(3, 3, [1, 3, 0, -2, -6, 0, 3, 9, 6])\n",
      " |      >>> M\n",
      " |      Matrix([\n",
      " |      [ 1,  3, 0],\n",
      " |      [-2, -6, 0],\n",
      " |      [ 3,  9, 6]])\n",
      " |      >>> M.columnspace()\n",
      " |      [Matrix([\n",
      " |      [ 1],\n",
      " |      [-2],\n",
      " |      [ 3]]), Matrix([\n",
      " |      [0],\n",
      " |      [0],\n",
      " |      [6]])]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      nullspace\n",
      " |      rowspace\n",
      " |  \n",
      " |  nullspace(self, simplify=False, iszerofunc=<function _iszero at 0x7f27787b60d0>)\n",
      " |      Returns list of vectors (Matrix objects) that span nullspace of ``M``\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix(3, 3, [1, 3, 0, -2, -6, 0, 3, 9, 6])\n",
      " |      >>> M\n",
      " |      Matrix([\n",
      " |      [ 1,  3, 0],\n",
      " |      [-2, -6, 0],\n",
      " |      [ 3,  9, 6]])\n",
      " |      >>> M.nullspace()\n",
      " |      [Matrix([\n",
      " |      [-3],\n",
      " |      [ 1],\n",
      " |      [ 0]])]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      columnspace\n",
      " |      rowspace\n",
      " |  \n",
      " |  rowspace(self, simplify=False)\n",
      " |      Returns a list of vectors that span the row space of ``M``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix(3, 3, [1, 3, 0, -2, -6, 0, 3, 9, 6])\n",
      " |      >>> M\n",
      " |      Matrix([\n",
      " |      [ 1,  3, 0],\n",
      " |      [-2, -6, 0],\n",
      " |      [ 3,  9, 6]])\n",
      " |      >>> M.rowspace()\n",
      " |      [Matrix([[1, 3, 0]]), Matrix([[0, 0, 6]])]\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.matrices.matrices.MatrixSubspaces:\n",
      " |  \n",
      " |  orthogonalize(*vecs, **kwargs) from builtins.type\n",
      " |      Apply the Gram-Schmidt orthogonalization procedure\n",
      " |      to vectors supplied in ``vecs``.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      vecs\n",
      " |          vectors to be made orthogonal\n",
      " |      \n",
      " |      normalize : bool\n",
      " |          If ``True``, return an orthonormal basis.\n",
      " |      \n",
      " |      rankcheck : bool\n",
      " |          If ``True``, the computation does not stop when encountering\n",
      " |          linearly dependent vectors.\n",
      " |      \n",
      " |          If ``False``, it will raise ``ValueError`` when any zero\n",
      " |          or linearly dependent vectors are found.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      list\n",
      " |          List of orthogonal (or orthonormal) basis vectors.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import I, Matrix\n",
      " |      >>> v = [Matrix([1, I]), Matrix([1, -I])]\n",
      " |      >>> Matrix.orthogonalize(*v)\n",
      " |      [Matrix([\n",
      " |      [1],\n",
      " |      [I]]), Matrix([\n",
      " |      [ 1],\n",
      " |      [-I]])]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      MatrixBase.QRdecomposition\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.matrices.MatrixReductions:\n",
      " |  \n",
      " |  echelon_form(self, iszerofunc=<function _iszero at 0x7f27787b60d0>, simplify=False, with_pivots=False)\n",
      " |      Returns a matrix row-equivalent to ``M`` that is in echelon form. Note\n",
      " |      that echelon form of a matrix is *not* unique, however, properties like the\n",
      " |      row space and the null space are preserved.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 2], [3, 4]])\n",
      " |      >>> M.echelon_form()\n",
      " |      Matrix([\n",
      " |      [1,  2],\n",
      " |      [0, -2]])\n",
      " |  \n",
      " |  elementary_col_op(self, op='n->kn', col=None, k=None, col1=None, col2=None)\n",
      " |      Performs the elementary column operation `op`.\n",
      " |      \n",
      " |      `op` may be one of\n",
      " |      \n",
      " |          * ``\"n->kn\"`` (column n goes to k*n)\n",
      " |          * ``\"n<->m\"`` (swap column n and column m)\n",
      " |          * ``\"n->n+km\"`` (column n goes to column n + k*column m)\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      op : string; the elementary row operation\n",
      " |      col : the column to apply the column operation\n",
      " |      k : the multiple to apply in the column operation\n",
      " |      col1 : one column of a column swap\n",
      " |      col2 : second column of a column swap or column \"m\" in the column operation\n",
      " |             \"n->n+km\"\n",
      " |  \n",
      " |  elementary_row_op(self, op='n->kn', row=None, k=None, row1=None, row2=None)\n",
      " |      Performs the elementary row operation `op`.\n",
      " |      \n",
      " |      `op` may be one of\n",
      " |      \n",
      " |          * ``\"n->kn\"`` (row n goes to k*n)\n",
      " |          * ``\"n<->m\"`` (swap row n and row m)\n",
      " |          * ``\"n->n+km\"`` (row n goes to row n + k*row m)\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      op : string; the elementary row operation\n",
      " |      row : the row to apply the row operation\n",
      " |      k : the multiple to apply in the row operation\n",
      " |      row1 : one row of a row swap\n",
      " |      row2 : second row of a row swap or row \"m\" in the row operation\n",
      " |             \"n->n+km\"\n",
      " |  \n",
      " |  rank(self, iszerofunc=<function _iszero at 0x7f27787b60d0>, simplify=False)\n",
      " |      Returns the rank of a matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> m = Matrix([[1, 2], [x, 1 - 1/x]])\n",
      " |      >>> m.rank()\n",
      " |      2\n",
      " |      >>> n = Matrix(3, 3, range(1, 10))\n",
      " |      >>> n.rank()\n",
      " |      2\n",
      " |  \n",
      " |  rref(self, iszerofunc=<function _iszero at 0x7f27787b60d0>, simplify=False, pivots=True, normalize_last=True)\n",
      " |      Return reduced row-echelon form of matrix and indices of pivot vars.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      iszerofunc : Function\n",
      " |          A function used for detecting whether an element can\n",
      " |          act as a pivot.  ``lambda x: x.is_zero`` is used by default.\n",
      " |      \n",
      " |      simplify : Function\n",
      " |          A function used to simplify elements when looking for a pivot.\n",
      " |          By default SymPy's ``simplify`` is used.\n",
      " |      \n",
      " |      pivots : True or False\n",
      " |          If ``True``, a tuple containing the row-reduced matrix and a tuple\n",
      " |          of pivot columns is returned.  If ``False`` just the row-reduced\n",
      " |          matrix is returned.\n",
      " |      \n",
      " |      normalize_last : True or False\n",
      " |          If ``True``, no pivots are normalized to `1` until after all\n",
      " |          entries above and below each pivot are zeroed.  This means the row\n",
      " |          reduction algorithm is fraction free until the very last step.\n",
      " |          If ``False``, the naive row reduction procedure is used where\n",
      " |          each pivot is normalized to be `1` before row operations are\n",
      " |          used to zero above and below the pivot.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> m = Matrix([[1, 2], [x, 1 - 1/x]])\n",
      " |      >>> m.rref()\n",
      " |      (Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]]), (0, 1))\n",
      " |      >>> rref_matrix, rref_pivots = m.rref()\n",
      " |      >>> rref_matrix\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]])\n",
      " |      >>> rref_pivots\n",
      " |      (0, 1)\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      The default value of ``normalize_last=True`` can provide significant\n",
      " |      speedup to row reduction, especially on matrices with symbols.  However,\n",
      " |      if you depend on the form row reduction algorithm leaves entries\n",
      " |      of the matrix, set ``noramlize_last=False``\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.matrices.matrices.MatrixReductions:\n",
      " |  \n",
      " |  is_echelon\n",
      " |      Returns `True` if the matrix is in echelon form. That is, all rows of\n",
      " |      zeros are at the bottom, and below each leading non-zero in a row are\n",
      " |      exclusively zeros.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.matrices.MatrixDeterminant:\n",
      " |  \n",
      " |  adjugate(self, method='berkowitz')\n",
      " |      Returns the adjugate, or classical adjoint, of\n",
      " |      a matrix.  That is, the transpose of the matrix of cofactors.\n",
      " |      \n",
      " |      https://en.wikipedia.org/wiki/Adjugate\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      method : string, optional\n",
      " |          Method to use to find the cofactors, can be \"bareiss\", \"berkowitz\" or\n",
      " |          \"lu\".\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 2], [3, 4]])\n",
      " |      >>> M.adjugate()\n",
      " |      Matrix([\n",
      " |      [ 4, -2],\n",
      " |      [-3,  1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      cofactor_matrix\n",
      " |      sympy.matrices.common.MatrixCommon.transpose\n",
      " |  \n",
      " |  charpoly(self, x='lambda', simplify=<function simplify at 0x7f27788a7940>)\n",
      " |      Computes characteristic polynomial det(x*I - M) where I is\n",
      " |      the identity matrix.\n",
      " |      \n",
      " |      A PurePoly is returned, so using different variables for ``x`` does\n",
      " |      not affect the comparison or the polynomials:\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      x : string, optional\n",
      " |          Name for the \"lambda\" variable, defaults to \"lambda\".\n",
      " |      \n",
      " |      simplify : function, optional\n",
      " |          Simplification function to use on the characteristic polynomial\n",
      " |          calculated. Defaults to ``simplify``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> M = Matrix([[1, 3], [2, 0]])\n",
      " |      >>> M.charpoly()\n",
      " |      PurePoly(lambda**2 - lambda - 6, lambda, domain='ZZ')\n",
      " |      >>> M.charpoly(x) == M.charpoly(y)\n",
      " |      True\n",
      " |      >>> M.charpoly(x) == M.charpoly(y)\n",
      " |      True\n",
      " |      \n",
      " |      Specifying ``x`` is optional; a symbol named ``lambda`` is used by\n",
      " |      default (which looks good when pretty-printed in unicode):\n",
      " |      \n",
      " |      >>> M.charpoly().as_expr()\n",
      " |      lambda**2 - lambda - 6\n",
      " |      \n",
      " |      And if ``x`` clashes with an existing symbol, underscores will\n",
      " |      be prepended to the name to make it unique:\n",
      " |      \n",
      " |      >>> M = Matrix([[1, 2], [x, 0]])\n",
      " |      >>> M.charpoly(x).as_expr()\n",
      " |      _x**2 - _x - 2*x\n",
      " |      \n",
      " |      Whether you pass a symbol or not, the generator can be obtained\n",
      " |      with the gen attribute since it may not be the same as the symbol\n",
      " |      that was passed:\n",
      " |      \n",
      " |      >>> M.charpoly(x).gen\n",
      " |      _x\n",
      " |      >>> M.charpoly(x).gen == x\n",
      " |      False\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      The Samuelson-Berkowitz algorithm is used to compute\n",
      " |      the characteristic polynomial efficiently and without any\n",
      " |      division operations.  Thus the characteristic polynomial over any\n",
      " |      commutative ring without zero divisors can be computed.\n",
      " |      \n",
      " |      If the determinant det(x*I - M) can be found out easily as\n",
      " |      in the case of an upper or a lower triangular matrix, then\n",
      " |      instead of Samuelson-Berkowitz algorithm, eigenvalues are computed\n",
      " |      and the characteristic polynomial with their help.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      det\n",
      " |  \n",
      " |  cofactor(self, i, j, method='berkowitz')\n",
      " |      Calculate the cofactor of an element.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      method : string, optional\n",
      " |          Method to use to find the cofactors, can be \"bareiss\", \"berkowitz\" or\n",
      " |          \"lu\".\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 2], [3, 4]])\n",
      " |      >>> M.cofactor(0, 1)\n",
      " |      -3\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      cofactor_matrix\n",
      " |      minor\n",
      " |      minor_submatrix\n",
      " |  \n",
      " |  cofactor_matrix(self, method='berkowitz')\n",
      " |      Return a matrix containing the cofactor of each element.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      method : string, optional\n",
      " |          Method to use to find the cofactors, can be \"bareiss\", \"berkowitz\" or\n",
      " |          \"lu\".\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 2], [3, 4]])\n",
      " |      >>> M.cofactor_matrix()\n",
      " |      Matrix([\n",
      " |      [ 4, -3],\n",
      " |      [-2,  1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      cofactor\n",
      " |      minor\n",
      " |      minor_submatrix\n",
      " |  \n",
      " |  det(self, method='bareiss', iszerofunc=None)\n",
      " |      Computes the determinant of a matrix if ``M`` is a concrete matrix object\n",
      " |      otherwise return an expressions ``Determinant(M)`` if ``M`` is a\n",
      " |      ``MatrixSymbol`` or other expression.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      method : string, optional\n",
      " |          Specifies the algorithm used for computing the matrix determinant.\n",
      " |      \n",
      " |          If the matrix is at most 3x3, a hard-coded formula is used and the\n",
      " |          specified method is ignored. Otherwise, it defaults to\n",
      " |          ``'bareiss'``.\n",
      " |      \n",
      " |          Also, if the matrix is an upper or a lower triangular matrix, determinant\n",
      " |          is computed by simple multiplication of diagonal elements, and the\n",
      " |          specified method is ignored.\n",
      " |      \n",
      " |          If it is set to ``'domain-ge'``, then Gaussian elimination method will\n",
      " |          be used via using DomainMatrix.\n",
      " |      \n",
      " |          If it is set to ``'bareiss'``, Bareiss' fraction-free algorithm will\n",
      " |          be used.\n",
      " |      \n",
      " |          If it is set to ``'berkowitz'``, Berkowitz' algorithm will be used.\n",
      " |      \n",
      " |          Otherwise, if it is set to ``'lu'``, LU decomposition will be used.\n",
      " |      \n",
      " |          .. note::\n",
      " |              For backward compatibility, legacy keys like \"bareis\" and\n",
      " |              \"det_lu\" can still be used to indicate the corresponding\n",
      " |              methods.\n",
      " |              And the keys are also case-insensitive for now. However, it is\n",
      " |              suggested to use the precise keys for specifying the method.\n",
      " |      \n",
      " |      iszerofunc : FunctionType or None, optional\n",
      " |          If it is set to ``None``, it will be defaulted to ``_iszero`` if the\n",
      " |          method is set to ``'bareiss'``, and ``_is_zero_after_expand_mul`` if\n",
      " |          the method is set to ``'lu'``.\n",
      " |      \n",
      " |          It can also accept any user-specified zero testing function, if it\n",
      " |          is formatted as a function which accepts a single symbolic argument\n",
      " |          and returns ``True`` if it is tested as zero and ``False`` if it\n",
      " |          tested as non-zero, and also ``None`` if it is undecidable.\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      det : Basic\n",
      " |          Result of determinant.\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      ValueError\n",
      " |          If unrecognized keys are given for ``method`` or ``iszerofunc``.\n",
      " |      \n",
      " |      NonSquareMatrixError\n",
      " |          If attempted to calculate determinant from a non-square matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, eye, det\n",
      " |      >>> I3 = eye(3)\n",
      " |      >>> det(I3)\n",
      " |      1\n",
      " |      >>> M = Matrix([[1, 2], [3, 4]])\n",
      " |      >>> det(M)\n",
      " |      -2\n",
      " |      >>> det(M) == M.det()\n",
      " |      True\n",
      " |      >>> M.det(method=\"domain-ge\")\n",
      " |      -2\n",
      " |  \n",
      " |  minor(self, i, j, method='berkowitz')\n",
      " |      Return the (i,j) minor of ``M``.  That is,\n",
      " |      return the determinant of the matrix obtained by deleting\n",
      " |      the `i`th row and `j`th column from ``M``.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      i, j : int\n",
      " |          The row and column to exclude to obtain the submatrix.\n",
      " |      \n",
      " |      method : string, optional\n",
      " |          Method to use to find the determinant of the submatrix, can be\n",
      " |          \"bareiss\", \"berkowitz\" or \"lu\".\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n",
      " |      >>> M.minor(1, 1)\n",
      " |      -12\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      minor_submatrix\n",
      " |      cofactor\n",
      " |      det\n",
      " |  \n",
      " |  minor_submatrix(self, i, j)\n",
      " |      Return the submatrix obtained by removing the `i`th row\n",
      " |      and `j`th column from ``M`` (works with Pythonic negative indices).\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      i, j : int\n",
      " |          The row and column to exclude to obtain the submatrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n",
      " |      >>> M.minor_submatrix(1, 1)\n",
      " |      Matrix([\n",
      " |      [1, 3],\n",
      " |      [7, 9]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      minor\n",
      " |      cofactor\n",
      " |  \n",
      " |  per(self)\n",
      " |      Returns the permanent of a matrix. Unlike determinant,\n",
      " |      permanent is defined for both square and non-square matrices.\n",
      " |      \n",
      " |      For an m x n matrix, with m less than or equal to n,\n",
      " |      it is given as the sum over the permutations s of size\n",
      " |      less than or equal to m on [1, 2, . . . n] of the product\n",
      " |      from i = 1 to m of M[i, s[i]]. Taking the transpose will\n",
      " |      not affect the value of the permanent.\n",
      " |      \n",
      " |      In the case of a square matrix, this is the same as the permutation\n",
      " |      definition of the determinant, but it does not take the sign of the\n",
      " |      permutation into account. Computing the permanent with this definition\n",
      " |      is quite inefficient, so here the Ryser formula is used.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n",
      " |      >>> M.per()\n",
      " |      450\n",
      " |      >>> M = Matrix([1, 5, 7])\n",
      " |      >>> M.per()\n",
      " |      13\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] Prof. Frank Ben's notes: https://math.berkeley.edu/~bernd/ban275.pdf\n",
      " |      .. [2] Wikipedia article on Permanent: https://en.wikipedia.org/wiki/Permanent_(mathematics)\n",
      " |      .. [3] https://reference.wolfram.com/language/ref/Permanent.html\n",
      " |      .. [4] Permanent of a rectangular matrix : https://arxiv.org/pdf/0904.3251.pdf\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.common.MatrixArithmetic:\n",
      " |  \n",
      " |  __abs__(self)\n",
      " |      Returns a new matrix with entry-wise absolute values.\n",
      " |  \n",
      " |  __add__(self, other)\n",
      " |      Return self + other, raising ShapeError if shapes do not match.\n",
      " |  \n",
      " |  __matmul__(self, other)\n",
      " |  \n",
      " |  __mod__(self, other)\n",
      " |  \n",
      " |  __mul__(self, other)\n",
      " |      Return self*other where other is either a scalar or a matrix\n",
      " |      of compatible dimensions.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[1, 2, 3], [4, 5, 6]])\n",
      " |      >>> 2*A == A*2 == Matrix([[2, 4, 6], [8, 10, 12]])\n",
      " |      True\n",
      " |      >>> B = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n",
      " |      >>> A*B\n",
      " |      Matrix([\n",
      " |      [30, 36, 42],\n",
      " |      [66, 81, 96]])\n",
      " |      >>> B*A\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      ShapeError: Matrices size mismatch.\n",
      " |      >>>\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      matrix_multiply_elementwise\n",
      " |  \n",
      " |  __neg__(self)\n",
      " |  \n",
      " |  __pow__(self, exp)\n",
      " |      Return self**exp a scalar or symbol.\n",
      " |  \n",
      " |  __radd__(self, other)\n",
      " |  \n",
      " |  __rmatmul__(self, other)\n",
      " |  \n",
      " |  __rmul__(self, other)\n",
      " |  \n",
      " |  __rsub__(self, a)\n",
      " |  \n",
      " |  __sub__(self, a)\n",
      " |  \n",
      " |  __truediv__(self, other)\n",
      " |  \n",
      " |  multiply(self, other, dotprodsimp=None)\n",
      " |      Same as __mul__() but with optional simplification.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      dotprodsimp : bool, optional\n",
      " |          Specifies whether intermediate term algebraic simplification is used\n",
      " |          during matrix multiplications to control expression blowup and thus\n",
      " |          speed up calculation. Default is off.\n",
      " |  \n",
      " |  multiply_elementwise(self, other)\n",
      " |      Return the Hadamard product (elementwise product) of A and B\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[0, 1, 2], [3, 4, 5]])\n",
      " |      >>> B = Matrix([[1, 10, 100], [100, 10, 1]])\n",
      " |      >>> A.multiply_elementwise(B)\n",
      " |      Matrix([\n",
      " |      [  0, 10, 200],\n",
      " |      [300, 40,   5]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.matrices.matrices.MatrixBase.cross\n",
      " |      sympy.matrices.matrices.MatrixBase.dot\n",
      " |      multiply\n",
      " |  \n",
      " |  pow(self, exp, method=None)\n",
      " |      Return self**exp a scalar or symbol.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      method : multiply, mulsimp, jordan, cayley\n",
      " |          If multiply then it returns exponentiation using recursion.\n",
      " |          If jordan then Jordan form exponentiation will be used.\n",
      " |          If cayley then the exponentiation is done using Cayley-Hamilton\n",
      " |          theorem.\n",
      " |          If mulsimp then the exponentiation is done using recursion\n",
      " |          with dotprodsimp. This specifies whether intermediate term\n",
      " |          algebraic simplification is used during naive matrix power to\n",
      " |          control expression blowup and thus speed up calculation.\n",
      " |          If None, then it heuristically decides which method to use.\n",
      " |  \n",
      " |  rmultiply(self, other, dotprodsimp=None)\n",
      " |      Same as __rmul__() but with optional simplification.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      dotprodsimp : bool, optional\n",
      " |          Specifies whether intermediate term algebraic simplification is used\n",
      " |          during matrix multiplications to control expression blowup and thus\n",
      " |          speed up calculation. Default is off.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.common.MatrixOperations:\n",
      " |  \n",
      " |  adjoint(self)\n",
      " |      Conjugate transpose or Hermitian conjugation.\n",
      " |  \n",
      " |  applyfunc(self, f)\n",
      " |      Apply a function to each element of the matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> m = Matrix(2, 2, lambda i, j: i*2+j)\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [0, 1],\n",
      " |      [2, 3]])\n",
      " |      >>> m.applyfunc(lambda i: 2*i)\n",
      " |      Matrix([\n",
      " |      [0, 2],\n",
      " |      [4, 6]])\n",
      " |  \n",
      " |  as_real_imag(self, deep=True, **hints)\n",
      " |      Returns a tuple containing the (real, imaginary) part of matrix.\n",
      " |  \n",
      " |  conjugate(self)\n",
      " |      Return the by-element conjugation.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import SparseMatrix, I\n",
      " |      >>> a = SparseMatrix(((1, 2 + I), (3, 4), (I, -I)))\n",
      " |      >>> a\n",
      " |      Matrix([\n",
      " |      [1, 2 + I],\n",
      " |      [3,     4],\n",
      " |      [I,    -I]])\n",
      " |      >>> a.C\n",
      " |      Matrix([\n",
      " |      [ 1, 2 - I],\n",
      " |      [ 3,     4],\n",
      " |      [-I,     I]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      transpose: Matrix transposition\n",
      " |      H: Hermite conjugation\n",
      " |      sympy.matrices.matrices.MatrixBase.D: Dirac conjugation\n",
      " |  \n",
      " |  doit(self, **kwargs)\n",
      " |  \n",
      " |  evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      " |      Apply evalf() to each element of self.\n",
      " |  \n",
      " |  expand(self, deep=True, modulus=None, power_base=True, power_exp=True, mul=True, log=True, multinomial=True, basic=True, **hints)\n",
      " |      Apply core.function.expand to each entry of the matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> Matrix(1, 1, [x*(x+1)])\n",
      " |      Matrix([[x*(x + 1)]])\n",
      " |      >>> _.expand()\n",
      " |      Matrix([[x**2 + x]])\n",
      " |  \n",
      " |  lower_triangular(self, k=0)\n",
      " |      returns the elements on and below the kth diagonal of a matrix.\n",
      " |      If k is not specified then simply returns lower-triangular portion\n",
      " |      of a matrix\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import ones\n",
      " |      >>> A = ones(4)\n",
      " |      >>> A.lower_triangular()\n",
      " |      Matrix([\n",
      " |      [1, 0, 0, 0],\n",
      " |      [1, 1, 0, 0],\n",
      " |      [1, 1, 1, 0],\n",
      " |      [1, 1, 1, 1]])\n",
      " |      \n",
      " |      >>> A.lower_triangular(-2)\n",
      " |      Matrix([\n",
      " |      [0, 0, 0, 0],\n",
      " |      [0, 0, 0, 0],\n",
      " |      [1, 0, 0, 0],\n",
      " |      [1, 1, 0, 0]])\n",
      " |      \n",
      " |      >>> A.lower_triangular(1)\n",
      " |      Matrix([\n",
      " |      [1, 1, 0, 0],\n",
      " |      [1, 1, 1, 0],\n",
      " |      [1, 1, 1, 1],\n",
      " |      [1, 1, 1, 1]])\n",
      " |  \n",
      " |  n(self, *args, **kwargs)\n",
      " |      Apply evalf() to each element of self.\n",
      " |  \n",
      " |  permute(self, perm, orientation='rows', direction='forward')\n",
      " |      Permute the rows or columns of a matrix by the given list of\n",
      " |      swaps.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      perm : Permutation, list, or list of lists\n",
      " |          A representation for the permutation.\n",
      " |      \n",
      " |          If it is ``Permutation``, it is used directly with some\n",
      " |          resizing with respect to the matrix size.\n",
      " |      \n",
      " |          If it is specified as list of lists,\n",
      " |          (e.g., ``[[0, 1], [0, 2]]``), then the permutation is formed\n",
      " |          from applying the product of cycles. The direction how the\n",
      " |          cyclic product is applied is described in below.\n",
      " |      \n",
      " |          If it is specified as a list, the list should represent\n",
      " |          an array form of a permutation. (e.g., ``[1, 2, 0]``) which\n",
      " |          would would form the swapping function\n",
      " |          `0 \\mapsto 1, 1 \\mapsto 2, 2\\mapsto 0`.\n",
      " |      \n",
      " |      orientation : 'rows', 'cols'\n",
      " |          A flag to control whether to permute the rows or the columns\n",
      " |      \n",
      " |      direction : 'forward', 'backward'\n",
      " |          A flag to control whether to apply the permutations from\n",
      " |          the start of the list first, or from the back of the list\n",
      " |          first.\n",
      " |      \n",
      " |          For example, if the permutation specification is\n",
      " |          ``[[0, 1], [0, 2]]``,\n",
      " |      \n",
      " |          If the flag is set to ``'forward'``, the cycle would be\n",
      " |          formed as `0 \\mapsto 2, 2 \\mapsto 1, 1 \\mapsto 0`.\n",
      " |      \n",
      " |          If the flag is set to ``'backward'``, the cycle would be\n",
      " |          formed as `0 \\mapsto 1, 1 \\mapsto 2, 2 \\mapsto 0`.\n",
      " |      \n",
      " |          If the argument ``perm`` is not in a form of list of lists,\n",
      " |          this flag takes no effect.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import eye\n",
      " |      >>> M = eye(3)\n",
      " |      >>> M.permute([[0, 1], [0, 2]], orientation='rows', direction='forward')\n",
      " |      Matrix([\n",
      " |      [0, 0, 1],\n",
      " |      [1, 0, 0],\n",
      " |      [0, 1, 0]])\n",
      " |      \n",
      " |      >>> from sympy import eye\n",
      " |      >>> M = eye(3)\n",
      " |      >>> M.permute([[0, 1], [0, 2]], orientation='rows', direction='backward')\n",
      " |      Matrix([\n",
      " |      [0, 1, 0],\n",
      " |      [0, 0, 1],\n",
      " |      [1, 0, 0]])\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      If a bijective function\n",
      " |      `\\sigma : \\mathbb{N}_0 \\rightarrow \\mathbb{N}_0` denotes the\n",
      " |      permutation.\n",
      " |      \n",
      " |      If the matrix `A` is the matrix to permute, represented as\n",
      " |      a horizontal or a vertical stack of vectors:\n",
      " |      \n",
      " |      .. math::\n",
      " |          A =\n",
      " |          \\begin{bmatrix}\n",
      " |          a_0 \\\\ a_1 \\\\ \\vdots \\\\ a_{n-1}\n",
      " |          \\end{bmatrix} =\n",
      " |          \\begin{bmatrix}\n",
      " |          \\alpha_0 & \\alpha_1 & \\cdots & \\alpha_{n-1}\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      If the matrix `B` is the result, the permutation of matrix rows\n",
      " |      is defined as:\n",
      " |      \n",
      " |      .. math::\n",
      " |          B := \\begin{bmatrix}\n",
      " |          a_{\\sigma(0)} \\\\ a_{\\sigma(1)} \\\\ \\vdots \\\\ a_{\\sigma(n-1)}\n",
      " |          \\end{bmatrix}\n",
      " |      \n",
      " |      And the permutation of matrix columns is defined as:\n",
      " |      \n",
      " |      .. math::\n",
      " |          B := \\begin{bmatrix}\n",
      " |          \\alpha_{\\sigma(0)} & \\alpha_{\\sigma(1)} &\n",
      " |          \\cdots & \\alpha_{\\sigma(n-1)}\n",
      " |          \\end{bmatrix}\n",
      " |  \n",
      " |  permute_cols(self, swaps, direction='forward')\n",
      " |      Alias for\n",
      " |      ``self.permute(swaps, orientation='cols', direction=direction)``\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      permute\n",
      " |  \n",
      " |  permute_rows(self, swaps, direction='forward')\n",
      " |      Alias for\n",
      " |      ``self.permute(swaps, orientation='rows', direction=direction)``\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      permute\n",
      " |  \n",
      " |  refine(self, assumptions=True)\n",
      " |      Apply refine to each element of the matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol, Matrix, Abs, sqrt, Q\n",
      " |      >>> x = Symbol('x')\n",
      " |      >>> Matrix([[Abs(x)**2, sqrt(x**2)],[sqrt(x**2), Abs(x)**2]])\n",
      " |      Matrix([\n",
      " |      [ Abs(x)**2, sqrt(x**2)],\n",
      " |      [sqrt(x**2),  Abs(x)**2]])\n",
      " |      >>> _.refine(Q.real(x))\n",
      " |      Matrix([\n",
      " |      [  x**2, Abs(x)],\n",
      " |      [Abs(x),   x**2]])\n",
      " |  \n",
      " |  replace(self, F, G, map=False, simultaneous=True, exact=None)\n",
      " |      Replaces Function F in Matrix entries with Function G.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, Function, Matrix\n",
      " |      >>> F, G = symbols('F, G', cls=Function)\n",
      " |      >>> M = Matrix(2, 2, lambda i, j: F(i+j)) ; M\n",
      " |      Matrix([\n",
      " |      [F(0), F(1)],\n",
      " |      [F(1), F(2)]])\n",
      " |      >>> N = M.replace(F,G)\n",
      " |      >>> N\n",
      " |      Matrix([\n",
      " |      [G(0), G(1)],\n",
      " |      [G(1), G(2)]])\n",
      " |  \n",
      " |  rot90(self, k=1)\n",
      " |      Rotates Matrix by 90 degrees\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      k : int\n",
      " |          Specifies how many times the matrix is rotated by 90 degrees\n",
      " |          (clockwise when positive, counter-clockwise when negative).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, symbols\n",
      " |      >>> A = Matrix(2, 2, symbols('a:d'))\n",
      " |      >>> A\n",
      " |      Matrix([\n",
      " |      [a, b],\n",
      " |      [c, d]])\n",
      " |      \n",
      " |      Rotating the matrix clockwise one time:\n",
      " |      \n",
      " |      >>> A.rot90(1)\n",
      " |      Matrix([\n",
      " |      [c, a],\n",
      " |      [d, b]])\n",
      " |      \n",
      " |      Rotating the matrix anticlockwise two times:\n",
      " |      \n",
      " |      >>> A.rot90(-2)\n",
      " |      Matrix([\n",
      " |      [d, c],\n",
      " |      [b, a]])\n",
      " |  \n",
      " |  subs(self, *args, **kwargs)\n",
      " |      Return a new matrix with subs applied to each entry.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> from sympy import SparseMatrix, Matrix\n",
      " |      >>> SparseMatrix(1, 1, [x])\n",
      " |      Matrix([[x]])\n",
      " |      >>> _.subs(x, y)\n",
      " |      Matrix([[y]])\n",
      " |      >>> Matrix(_).subs(y, x)\n",
      " |      Matrix([[x]])\n",
      " |  \n",
      " |  trace(self)\n",
      " |      Returns the trace of a square matrix i.e. the sum of the\n",
      " |      diagonal elements.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix(2, 2, [1, 2, 3, 4])\n",
      " |      >>> A.trace()\n",
      " |      5\n",
      " |  \n",
      " |  transpose(self)\n",
      " |      Returns the transpose of the matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix(2, 2, [1, 2, 3, 4])\n",
      " |      >>> A.transpose()\n",
      " |      Matrix([\n",
      " |      [1, 3],\n",
      " |      [2, 4]])\n",
      " |      \n",
      " |      >>> from sympy import Matrix, I\n",
      " |      >>> m=Matrix(((1, 2+I), (3, 4)))\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 2 + I],\n",
      " |      [3,     4]])\n",
      " |      >>> m.transpose()\n",
      " |      Matrix([\n",
      " |      [    1, 3],\n",
      " |      [2 + I, 4]])\n",
      " |      >>> m.T == m.transpose()\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      conjugate: By-element conjugation\n",
      " |  \n",
      " |  upper_triangular(self, k=0)\n",
      " |      returns the elements on and above the kth diagonal of a matrix.\n",
      " |      If k is not specified then simply returns upper-triangular portion\n",
      " |      of a matrix\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import ones\n",
      " |      >>> A = ones(4)\n",
      " |      >>> A.upper_triangular()\n",
      " |      Matrix([\n",
      " |      [1, 1, 1, 1],\n",
      " |      [0, 1, 1, 1],\n",
      " |      [0, 0, 1, 1],\n",
      " |      [0, 0, 0, 1]])\n",
      " |      \n",
      " |      >>> A.upper_triangular(2)\n",
      " |      Matrix([\n",
      " |      [0, 0, 1, 1],\n",
      " |      [0, 0, 0, 1],\n",
      " |      [0, 0, 0, 0],\n",
      " |      [0, 0, 0, 0]])\n",
      " |      \n",
      " |      >>> A.upper_triangular(-1)\n",
      " |      Matrix([\n",
      " |      [1, 1, 1, 1],\n",
      " |      [1, 1, 1, 1],\n",
      " |      [0, 1, 1, 1],\n",
      " |      [0, 0, 1, 1]])\n",
      " |  \n",
      " |  xreplace(self, rule)\n",
      " |      Return a new matrix with xreplace applied to each entry.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> from sympy import SparseMatrix, Matrix\n",
      " |      >>> SparseMatrix(1, 1, [x])\n",
      " |      Matrix([[x]])\n",
      " |      >>> _.xreplace({x: y})\n",
      " |      Matrix([[y]])\n",
      " |      >>> Matrix(_).xreplace({y: x})\n",
      " |      Matrix([[x]])\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.matrices.common.MatrixOperations:\n",
      " |  \n",
      " |  C\n",
      " |      By-element conjugation\n",
      " |  \n",
      " |  H\n",
      " |      Return Hermite conjugate.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, I\n",
      " |      >>> m = Matrix((0, 1 + I, 2, 3))\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [    0],\n",
      " |      [1 + I],\n",
      " |      [    2],\n",
      " |      [    3]])\n",
      " |      >>> m.H\n",
      " |      Matrix([[0, 1 - I, 2, 3]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      conjugate: By-element conjugation\n",
      " |      sympy.matrices.matrices.MatrixBase.D: Dirac conjugation\n",
      " |  \n",
      " |  T\n",
      " |      Matrix transposition\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.common.MatrixProperties:\n",
      " |  \n",
      " |  atoms(self, *types)\n",
      " |      Returns the atoms that form the current object.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> Matrix([[x]])\n",
      " |      Matrix([[x]])\n",
      " |      >>> _.atoms()\n",
      " |      {x}\n",
      " |      >>> Matrix([[x, y], [y, x]])\n",
      " |      Matrix([\n",
      " |      [x, y],\n",
      " |      [y, x]])\n",
      " |      >>> _.atoms()\n",
      " |      {x, y}\n",
      " |  \n",
      " |  has(self, *patterns)\n",
      " |      Test whether any subexpression matches any of the patterns.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, SparseMatrix, Float\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> A = Matrix(((1, x), (0.2, 3)))\n",
      " |      >>> B = SparseMatrix(((1, x), (0.2, 3)))\n",
      " |      >>> A.has(x)\n",
      " |      True\n",
      " |      >>> A.has(y)\n",
      " |      False\n",
      " |      >>> A.has(Float)\n",
      " |      True\n",
      " |      >>> B.has(x)\n",
      " |      True\n",
      " |      >>> B.has(y)\n",
      " |      False\n",
      " |      >>> B.has(Float)\n",
      " |      True\n",
      " |  \n",
      " |  is_anti_symmetric(self, simplify=True)\n",
      " |      Check if matrix M is an antisymmetric matrix,\n",
      " |      that is, M is a square matrix with all M[i, j] == -M[j, i].\n",
      " |      \n",
      " |      When ``simplify=True`` (default), the sum M[i, j] + M[j, i] is\n",
      " |      simplified before testing to see if it is zero. By default,\n",
      " |      the SymPy simplify function is used. To use a custom function\n",
      " |      set simplify to a function that accepts a single argument which\n",
      " |      returns a simplified expression. To skip simplification, set\n",
      " |      simplify to False but note that although this will be faster,\n",
      " |      it may induce false negatives.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, symbols\n",
      " |      >>> m = Matrix(2, 2, [0, 1, -1, 0])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [ 0, 1],\n",
      " |      [-1, 0]])\n",
      " |      >>> m.is_anti_symmetric()\n",
      " |      True\n",
      " |      >>> x, y = symbols('x y')\n",
      " |      >>> m = Matrix(2, 3, [0, 0, x, -y, 0, 0])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [ 0, 0, x],\n",
      " |      [-y, 0, 0]])\n",
      " |      >>> m.is_anti_symmetric()\n",
      " |      False\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> m = Matrix(3, 3, [0, x**2 + 2*x + 1, y,\n",
      " |      ...                   -(x + 1)**2, 0, x*y,\n",
      " |      ...                   -y, -x*y, 0])\n",
      " |      \n",
      " |      Simplification of matrix elements is done by default so even\n",
      " |      though two elements which should be equal and opposite wouldn't\n",
      " |      pass an equality test, the matrix is still reported as\n",
      " |      anti-symmetric:\n",
      " |      \n",
      " |      >>> m[0, 1] == -m[1, 0]\n",
      " |      False\n",
      " |      >>> m.is_anti_symmetric()\n",
      " |      True\n",
      " |      \n",
      " |      If 'simplify=False' is used for the case when a Matrix is already\n",
      " |      simplified, this will speed things up. Here, we see that without\n",
      " |      simplification the matrix does not appear anti-symmetric:\n",
      " |      \n",
      " |      >>> m.is_anti_symmetric(simplify=False)\n",
      " |      False\n",
      " |      \n",
      " |      But if the matrix were already expanded, then it would appear\n",
      " |      anti-symmetric and simplification in the is_anti_symmetric routine\n",
      " |      is not needed:\n",
      " |      \n",
      " |      >>> m = m.expand()\n",
      " |      >>> m.is_anti_symmetric(simplify=False)\n",
      " |      True\n",
      " |  \n",
      " |  is_diagonal(self)\n",
      " |      Check if matrix is diagonal,\n",
      " |      that is matrix in which the entries outside the main diagonal are all zero.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, diag\n",
      " |      >>> m = Matrix(2, 2, [1, 0, 0, 2])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 2]])\n",
      " |      >>> m.is_diagonal()\n",
      " |      True\n",
      " |      \n",
      " |      >>> m = Matrix(2, 2, [1, 1, 0, 2])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 1],\n",
      " |      [0, 2]])\n",
      " |      >>> m.is_diagonal()\n",
      " |      False\n",
      " |      \n",
      " |      >>> m = diag(1, 2, 3)\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 2, 0],\n",
      " |      [0, 0, 3]])\n",
      " |      >>> m.is_diagonal()\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      is_lower\n",
      " |      is_upper\n",
      " |      sympy.matrices.matrices.MatrixEigen.is_diagonalizable\n",
      " |      diagonalize\n",
      " |  \n",
      " |  is_symbolic(self)\n",
      " |      Checks if any elements contain Symbols.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> M = Matrix([[x, y], [1, 0]])\n",
      " |      >>> M.is_symbolic()\n",
      " |      True\n",
      " |  \n",
      " |  is_symmetric(self, simplify=True)\n",
      " |      Check if matrix is symmetric matrix,\n",
      " |      that is square matrix and is equal to its transpose.\n",
      " |      \n",
      " |      By default, simplifications occur before testing symmetry.\n",
      " |      They can be skipped using 'simplify=False'; while speeding things a bit,\n",
      " |      this may however induce false negatives.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> m = Matrix(2, 2, [0, 1, 1, 2])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [0, 1],\n",
      " |      [1, 2]])\n",
      " |      >>> m.is_symmetric()\n",
      " |      True\n",
      " |      \n",
      " |      >>> m = Matrix(2, 2, [0, 1, 2, 0])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [0, 1],\n",
      " |      [2, 0]])\n",
      " |      >>> m.is_symmetric()\n",
      " |      False\n",
      " |      \n",
      " |      >>> m = Matrix(2, 3, [0, 0, 0, 0, 0, 0])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [0, 0, 0],\n",
      " |      [0, 0, 0]])\n",
      " |      >>> m.is_symmetric()\n",
      " |      False\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> m = Matrix(3, 3, [1, x**2 + 2*x + 1, y, (x + 1)**2, 2, 0, y, 0, 3])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [         1, x**2 + 2*x + 1, y],\n",
      " |      [(x + 1)**2,              2, 0],\n",
      " |      [         y,              0, 3]])\n",
      " |      >>> m.is_symmetric()\n",
      " |      True\n",
      " |      \n",
      " |      If the matrix is already simplified, you may speed-up is_symmetric()\n",
      " |      test by using 'simplify=False'.\n",
      " |      \n",
      " |      >>> bool(m.is_symmetric(simplify=False))\n",
      " |      False\n",
      " |      >>> m1 = m.expand()\n",
      " |      >>> m1.is_symmetric(simplify=False)\n",
      " |      True\n",
      " |  \n",
      " |  values(self)\n",
      " |      Return non-zero values of self.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.matrices.common.MatrixProperties:\n",
      " |  \n",
      " |  free_symbols\n",
      " |      Returns the free symbols within the matrix.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> Matrix([[x], [1]]).free_symbols\n",
      " |      {x}\n",
      " |  \n",
      " |  is_Identity\n",
      " |  \n",
      " |  is_hermitian\n",
      " |      Checks if the matrix is Hermitian.\n",
      " |      \n",
      " |      In a Hermitian matrix element i,j is the complex conjugate of\n",
      " |      element j,i.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy import I\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> a = Matrix([[1, I], [-I, 1]])\n",
      " |      >>> a\n",
      " |      Matrix([\n",
      " |      [ 1, I],\n",
      " |      [-I, 1]])\n",
      " |      >>> a.is_hermitian\n",
      " |      True\n",
      " |      >>> a[0, 0] = 2*I\n",
      " |      >>> a.is_hermitian\n",
      " |      False\n",
      " |      >>> a[0, 0] = x\n",
      " |      >>> a.is_hermitian\n",
      " |      >>> a[0, 1] = a[1, 0]*I\n",
      " |      >>> a.is_hermitian\n",
      " |      False\n",
      " |  \n",
      " |  is_lower\n",
      " |      Check if matrix is a lower triangular matrix. True can be returned\n",
      " |      even if the matrix is not square.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> m = Matrix(2, 2, [1, 0, 0, 1])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]])\n",
      " |      >>> m.is_lower\n",
      " |      True\n",
      " |      \n",
      " |      >>> m = Matrix(4, 3, [0, 0, 0, 2, 0, 0, 1, 4, 0, 6, 6, 5])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [0, 0, 0],\n",
      " |      [2, 0, 0],\n",
      " |      [1, 4, 0],\n",
      " |      [6, 6, 5]])\n",
      " |      >>> m.is_lower\n",
      " |      True\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> m = Matrix(2, 2, [x**2 + y, y**2 + x, 0, x + y])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [x**2 + y, x + y**2],\n",
      " |      [       0,    x + y]])\n",
      " |      >>> m.is_lower\n",
      " |      False\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      is_upper\n",
      " |      is_diagonal\n",
      " |      is_lower_hessenberg\n",
      " |  \n",
      " |  is_lower_hessenberg\n",
      " |      Checks if the matrix is in the lower-Hessenberg form.\n",
      " |      \n",
      " |      The lower hessenberg matrix has zero entries\n",
      " |      above the first superdiagonal.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> a = Matrix([[1, 2, 0, 0], [5, 2, 3, 0], [3, 4, 3, 7], [5, 6, 1, 1]])\n",
      " |      >>> a\n",
      " |      Matrix([\n",
      " |      [1, 2, 0, 0],\n",
      " |      [5, 2, 3, 0],\n",
      " |      [3, 4, 3, 7],\n",
      " |      [5, 6, 1, 1]])\n",
      " |      >>> a.is_lower_hessenberg\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      is_upper_hessenberg\n",
      " |      is_lower\n",
      " |  \n",
      " |  is_square\n",
      " |      Checks if a matrix is square.\n",
      " |      \n",
      " |      A matrix is square if the number of rows equals the number of columns.\n",
      " |      The empty matrix is square by definition, since the number of rows and\n",
      " |      the number of columns are both zero.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> a = Matrix([[1, 2, 3], [4, 5, 6]])\n",
      " |      >>> b = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n",
      " |      >>> c = Matrix([])\n",
      " |      >>> a.is_square\n",
      " |      False\n",
      " |      >>> b.is_square\n",
      " |      True\n",
      " |      >>> c.is_square\n",
      " |      True\n",
      " |  \n",
      " |  is_strongly_diagonally_dominant\n",
      " |      Tests if the matrix is row strongly diagonally dominant.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A $n, n$ matrix $A$ is row strongly diagonally dominant if\n",
      " |      \n",
      " |      .. math::\n",
      " |          \\left|A_{i, i}\\right| > \\sum_{j = 0, j \\neq i}^{n-1}\n",
      " |          \\left|A_{i, j}\\right| \\quad {\\text{for all }}\n",
      " |          i \\in \\{ 0, ..., n-1 \\}\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[3, -2, 1], [1, -3, 2], [-1, 2, 4]])\n",
      " |      >>> A.is_strongly_diagonally_dominant\n",
      " |      False\n",
      " |      \n",
      " |      >>> A = Matrix([[-2, 2, 1], [1, 3, 2], [1, -2, 0]])\n",
      " |      >>> A.is_strongly_diagonally_dominant\n",
      " |      False\n",
      " |      \n",
      " |      >>> A = Matrix([[-4, 2, 1], [1, 6, 2], [1, -2, 5]])\n",
      " |      >>> A.is_strongly_diagonally_dominant\n",
      " |      True\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      If you want to test whether a matrix is column diagonally\n",
      " |      dominant, you can apply the test after transposing the matrix.\n",
      " |  \n",
      " |  is_upper\n",
      " |      Check if matrix is an upper triangular matrix. True can be returned\n",
      " |      even if the matrix is not square.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> m = Matrix(2, 2, [1, 0, 0, 1])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1]])\n",
      " |      >>> m.is_upper\n",
      " |      True\n",
      " |      \n",
      " |      >>> m = Matrix(4, 3, [5, 1, 9, 0, 4, 6, 0, 0, 5, 0, 0, 0])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [5, 1, 9],\n",
      " |      [0, 4, 6],\n",
      " |      [0, 0, 5],\n",
      " |      [0, 0, 0]])\n",
      " |      >>> m.is_upper\n",
      " |      True\n",
      " |      \n",
      " |      >>> m = Matrix(2, 3, [4, 2, 5, 6, 1, 1])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [4, 2, 5],\n",
      " |      [6, 1, 1]])\n",
      " |      >>> m.is_upper\n",
      " |      False\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      is_lower\n",
      " |      is_diagonal\n",
      " |      is_upper_hessenberg\n",
      " |  \n",
      " |  is_upper_hessenberg\n",
      " |      Checks if the matrix is the upper-Hessenberg form.\n",
      " |      \n",
      " |      The upper hessenberg matrix has zero entries\n",
      " |      below the first subdiagonal.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> a = Matrix([[1, 4, 2, 3], [3, 4, 1, 7], [0, 2, 3, 4], [0, 0, 1, 3]])\n",
      " |      >>> a\n",
      " |      Matrix([\n",
      " |      [1, 4, 2, 3],\n",
      " |      [3, 4, 1, 7],\n",
      " |      [0, 2, 3, 4],\n",
      " |      [0, 0, 1, 3]])\n",
      " |      >>> a.is_upper_hessenberg\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      is_lower_hessenberg\n",
      " |      is_upper\n",
      " |  \n",
      " |  is_weakly_diagonally_dominant\n",
      " |      Tests if the matrix is row weakly diagonally dominant.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A $n, n$ matrix $A$ is row weakly diagonally dominant if\n",
      " |      \n",
      " |      .. math::\n",
      " |          \\left|A_{i, i}\\right| \\ge \\sum_{j = 0, j \\neq i}^{n-1}\n",
      " |          \\left|A_{i, j}\\right| \\quad {\\text{for all }}\n",
      " |          i \\in \\{ 0, ..., n-1 \\}\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[3, -2, 1], [1, -3, 2], [-1, 2, 4]])\n",
      " |      >>> A.is_weakly_diagonally_dominant\n",
      " |      True\n",
      " |      \n",
      " |      >>> A = Matrix([[-2, 2, 1], [1, 3, 2], [1, -2, 0]])\n",
      " |      >>> A.is_weakly_diagonally_dominant\n",
      " |      False\n",
      " |      \n",
      " |      >>> A = Matrix([[-4, 2, 1], [1, 6, 2], [1, -2, 5]])\n",
      " |      >>> A.is_weakly_diagonally_dominant\n",
      " |      True\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      If you want to test whether a matrix is column diagonally\n",
      " |      dominant, you can apply the test after transposing the matrix.\n",
      " |  \n",
      " |  is_zero_matrix\n",
      " |      Checks if a matrix is a zero matrix.\n",
      " |      \n",
      " |      A matrix is zero if every element is zero.  A matrix need not be square\n",
      " |      to be considered zero.  The empty matrix is zero by the principle of\n",
      " |      vacuous truth.  For a matrix that may or may not be zero (e.g.\n",
      " |      contains a symbol), this will be None\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, zeros\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> a = Matrix([[0, 0], [0, 0]])\n",
      " |      >>> b = zeros(3, 4)\n",
      " |      >>> c = Matrix([[0, 1], [0, 0]])\n",
      " |      >>> d = Matrix([])\n",
      " |      >>> e = Matrix([[x, 0], [0, 0]])\n",
      " |      >>> a.is_zero_matrix\n",
      " |      True\n",
      " |      >>> b.is_zero_matrix\n",
      " |      True\n",
      " |      >>> c.is_zero_matrix\n",
      " |      False\n",
      " |      >>> d.is_zero_matrix\n",
      " |      True\n",
      " |      >>> e.is_zero_matrix\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.matrices.common.MatrixSpecial:\n",
      " |  \n",
      " |  companion(poly) from builtins.type\n",
      " |      Returns a companion matrix of a polynomial.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, Poly, Symbol, symbols\n",
      " |      >>> x = Symbol('x')\n",
      " |      >>> c0, c1, c2, c3, c4 = symbols('c0:5')\n",
      " |      >>> p = Poly(c0 + c1*x + c2*x**2 + c3*x**3 + c4*x**4 + x**5, x)\n",
      " |      >>> Matrix.companion(p)\n",
      " |      Matrix([\n",
      " |      [0, 0, 0, 0, -c0],\n",
      " |      [1, 0, 0, 0, -c1],\n",
      " |      [0, 1, 0, 0, -c2],\n",
      " |      [0, 0, 1, 0, -c3],\n",
      " |      [0, 0, 0, 1, -c4]])\n",
      " |  \n",
      " |  diag(*args, strict=False, unpack=True, rows=None, cols=None, **kwargs) from builtins.type\n",
      " |      Returns a matrix with the specified diagonal.\n",
      " |      If matrices are passed, a block-diagonal matrix\n",
      " |      is created (i.e. the \"direct sum\" of the matrices).\n",
      " |      \n",
      " |      kwargs\n",
      " |      ======\n",
      " |      \n",
      " |      rows : rows of the resulting matrix; computed if\n",
      " |             not given.\n",
      " |      \n",
      " |      cols : columns of the resulting matrix; computed if\n",
      " |             not given.\n",
      " |      \n",
      " |      cls : class for the resulting matrix\n",
      " |      \n",
      " |      unpack : bool which, when True (default), unpacks a single\n",
      " |      sequence rather than interpreting it as a Matrix.\n",
      " |      \n",
      " |      strict : bool which, when False (default), allows Matrices to\n",
      " |      have variable-length rows.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> Matrix.diag(1, 2, 3)\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [0, 2, 0],\n",
      " |      [0, 0, 3]])\n",
      " |      \n",
      " |      The current default is to unpack a single sequence. If this is\n",
      " |      not desired, set `unpack=False` and it will be interpreted as\n",
      " |      a matrix.\n",
      " |      \n",
      " |      >>> Matrix.diag([1, 2, 3]) == Matrix.diag(1, 2, 3)\n",
      " |      True\n",
      " |      \n",
      " |      When more than one element is passed, each is interpreted as\n",
      " |      something to put on the diagonal. Lists are converted to\n",
      " |      matrices. Filling of the diagonal always continues from\n",
      " |      the bottom right hand corner of the previous item: this\n",
      " |      will create a block-diagonal matrix whether the matrices\n",
      " |      are square or not.\n",
      " |      \n",
      " |      >>> col = [1, 2, 3]\n",
      " |      >>> row = [[4, 5]]\n",
      " |      >>> Matrix.diag(col, row)\n",
      " |      Matrix([\n",
      " |      [1, 0, 0],\n",
      " |      [2, 0, 0],\n",
      " |      [3, 0, 0],\n",
      " |      [0, 4, 5]])\n",
      " |      \n",
      " |      When `unpack` is False, elements within a list need not all be\n",
      " |      of the same length. Setting `strict` to True would raise a\n",
      " |      ValueError for the following:\n",
      " |      \n",
      " |      >>> Matrix.diag([[1, 2, 3], [4, 5], [6]], unpack=False)\n",
      " |      Matrix([\n",
      " |      [1, 2, 3],\n",
      " |      [4, 5, 0],\n",
      " |      [6, 0, 0]])\n",
      " |      \n",
      " |      The type of the returned matrix can be set with the ``cls``\n",
      " |      keyword.\n",
      " |      \n",
      " |      >>> from sympy import ImmutableMatrix\n",
      " |      >>> from sympy.utilities.misc import func_name\n",
      " |      >>> func_name(Matrix.diag(1, cls=ImmutableMatrix))\n",
      " |      'ImmutableDenseMatrix'\n",
      " |      \n",
      " |      A zero dimension matrix can be used to position the start of\n",
      " |      the filling at the start of an arbitrary row or column:\n",
      " |      \n",
      " |      >>> from sympy import ones\n",
      " |      >>> r2 = ones(0, 2)\n",
      " |      >>> Matrix.diag(r2, 1, 2)\n",
      " |      Matrix([\n",
      " |      [0, 0, 1, 0],\n",
      " |      [0, 0, 0, 2]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      eye\n",
      " |      diagonal - to extract a diagonal\n",
      " |      .dense.diag\n",
      " |      .expressions.blockmatrix.BlockMatrix\n",
      " |      .sparsetools.banded - to create multi-diagonal matrices\n",
      " |  \n",
      " |  eye(rows, cols=None, **kwargs) from builtins.type\n",
      " |      Returns an identity matrix.\n",
      " |      \n",
      " |      Args\n",
      " |      ====\n",
      " |      \n",
      " |      rows : rows of the matrix\n",
      " |      cols : cols of the matrix (if None, cols=rows)\n",
      " |      \n",
      " |      kwargs\n",
      " |      ======\n",
      " |      cls : class of the returned matrix\n",
      " |  \n",
      " |  jordan_block(size=None, eigenvalue=None, *, band='upper', **kwargs) from builtins.type\n",
      " |      Returns a Jordan block\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      size : Integer, optional\n",
      " |          Specifies the shape of the Jordan block matrix.\n",
      " |      \n",
      " |      eigenvalue : Number or Symbol\n",
      " |          Specifies the value for the main diagonal of the matrix.\n",
      " |      \n",
      " |          .. note::\n",
      " |              The keyword ``eigenval`` is also specified as an alias\n",
      " |              of this keyword, but it is not recommended to use.\n",
      " |      \n",
      " |              We may deprecate the alias in later release.\n",
      " |      \n",
      " |      band : 'upper' or 'lower', optional\n",
      " |          Specifies the position of the off-diagonal to put `1` s on.\n",
      " |      \n",
      " |      cls : Matrix, optional\n",
      " |          Specifies the matrix class of the output form.\n",
      " |      \n",
      " |          If it is not specified, the class type where the method is\n",
      " |          being executed on will be returned.\n",
      " |      \n",
      " |      rows, cols : Integer, optional\n",
      " |          Specifies the shape of the Jordan block matrix. See Notes\n",
      " |          section for the details of how these key works.\n",
      " |      \n",
      " |          .. deprecated:: 1.4\n",
      " |              The rows and cols parameters are deprecated and will be\n",
      " |              removed in a future version.\n",
      " |      \n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      Matrix\n",
      " |          A Jordan block matrix.\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      ValueError\n",
      " |          If insufficient arguments are given for matrix size\n",
      " |          specification, or no eigenvalue is given.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      Creating a default Jordan block:\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> Matrix.jordan_block(4, x)\n",
      " |      Matrix([\n",
      " |      [x, 1, 0, 0],\n",
      " |      [0, x, 1, 0],\n",
      " |      [0, 0, x, 1],\n",
      " |      [0, 0, 0, x]])\n",
      " |      \n",
      " |      Creating an alternative Jordan block matrix where `1` is on\n",
      " |      lower off-diagonal:\n",
      " |      \n",
      " |      >>> Matrix.jordan_block(4, x, band='lower')\n",
      " |      Matrix([\n",
      " |      [x, 0, 0, 0],\n",
      " |      [1, x, 0, 0],\n",
      " |      [0, 1, x, 0],\n",
      " |      [0, 0, 1, x]])\n",
      " |      \n",
      " |      Creating a Jordan block with keyword arguments\n",
      " |      \n",
      " |      >>> Matrix.jordan_block(size=4, eigenvalue=x)\n",
      " |      Matrix([\n",
      " |      [x, 1, 0, 0],\n",
      " |      [0, x, 1, 0],\n",
      " |      [0, 0, x, 1],\n",
      " |      [0, 0, 0, x]])\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      .. deprecated:: 1.4\n",
      " |          This feature is deprecated and will be removed in a future\n",
      " |          version.\n",
      " |      \n",
      " |      The keyword arguments ``size``, ``rows``, ``cols`` relates to\n",
      " |      the Jordan block size specifications.\n",
      " |      \n",
      " |      If you want to create a square Jordan block, specify either\n",
      " |      one of the three arguments.\n",
      " |      \n",
      " |      If you want to create a rectangular Jordan block, specify\n",
      " |      ``rows`` and ``cols`` individually.\n",
      " |      \n",
      " |      +--------------------------------+---------------------+\n",
      " |      |        Arguments Given         |     Matrix Shape    |\n",
      " |      +----------+----------+----------+----------+----------+\n",
      " |      |   size   |   rows   |   cols   |   rows   |   cols   |\n",
      " |      +==========+==========+==========+==========+==========+\n",
      " |      |   size   |         Any         |   size   |   size   |\n",
      " |      +----------+----------+----------+----------+----------+\n",
      " |      |          |        None         |     ValueError      |\n",
      " |      |          +----------+----------+----------+----------+\n",
      " |      |   None   |   rows   |   None   |   rows   |   rows   |\n",
      " |      |          +----------+----------+----------+----------+\n",
      " |      |          |   None   |   cols   |   cols   |   cols   |\n",
      " |      +          +----------+----------+----------+----------+\n",
      " |      |          |   rows   |   cols   |   rows   |   cols   |\n",
      " |      +----------+----------+----------+----------+----------+\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Jordan_matrix\n",
      " |  \n",
      " |  ones(rows, cols=None, **kwargs) from builtins.type\n",
      " |      Returns a matrix of ones.\n",
      " |      \n",
      " |      Args\n",
      " |      ====\n",
      " |      \n",
      " |      rows : rows of the matrix\n",
      " |      cols : cols of the matrix (if None, cols=rows)\n",
      " |      \n",
      " |      kwargs\n",
      " |      ======\n",
      " |      cls : class of the returned matrix\n",
      " |  \n",
      " |  wilkinson(n, **kwargs) from builtins.type\n",
      " |      Returns two square Wilkinson Matrix of size 2*n + 1\n",
      " |      $W_{2n + 1}^-, W_{2n + 1}^+ =$ Wilkinson(n)\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> wminus, wplus = Matrix.wilkinson(3)\n",
      " |      >>> wminus\n",
      " |      Matrix([\n",
      " |      [-3,  1,  0, 0, 0, 0, 0],\n",
      " |      [ 1, -2,  1, 0, 0, 0, 0],\n",
      " |      [ 0,  1, -1, 1, 0, 0, 0],\n",
      " |      [ 0,  0,  1, 0, 1, 0, 0],\n",
      " |      [ 0,  0,  0, 1, 1, 1, 0],\n",
      " |      [ 0,  0,  0, 0, 1, 2, 1],\n",
      " |      [ 0,  0,  0, 0, 0, 1, 3]])\n",
      " |      >>> wplus\n",
      " |      Matrix([\n",
      " |      [3, 1, 0, 0, 0, 0, 0],\n",
      " |      [1, 2, 1, 0, 0, 0, 0],\n",
      " |      [0, 1, 1, 1, 0, 0, 0],\n",
      " |      [0, 0, 1, 0, 1, 0, 0],\n",
      " |      [0, 0, 0, 1, 1, 1, 0],\n",
      " |      [0, 0, 0, 0, 1, 2, 1],\n",
      " |      [0, 0, 0, 0, 0, 1, 3]])\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://blogs.mathworks.com/cleve/2013/04/15/wilkinsons-matrices-2/\n",
      " |      .. [2] J. H. Wilkinson, The Algebraic Eigenvalue Problem, Claredon Press, Oxford, 1965, 662 pp.\n",
      " |  \n",
      " |  zeros(rows, cols=None, **kwargs) from builtins.type\n",
      " |      Returns a matrix of zeros.\n",
      " |      \n",
      " |      Args\n",
      " |      ====\n",
      " |      \n",
      " |      rows : rows of the matrix\n",
      " |      cols : cols of the matrix (if None, cols=rows)\n",
      " |      \n",
      " |      kwargs\n",
      " |      ======\n",
      " |      cls : class of the returned matrix\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.matrices.common.MatrixShaping:\n",
      " |  \n",
      " |  col(self, j)\n",
      " |      Elementary column selector.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import eye\n",
      " |      >>> eye(2).col(0)\n",
      " |      Matrix([\n",
      " |      [1],\n",
      " |      [0]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      row\n",
      " |      col_del\n",
      " |      col_join\n",
      " |      col_insert\n",
      " |  \n",
      " |  col_del(self, col)\n",
      " |      Delete the specified column.\n",
      " |  \n",
      " |  col_insert(self, pos, other)\n",
      " |      Insert one or more columns at the given column position.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import zeros, ones\n",
      " |      >>> M = zeros(3)\n",
      " |      >>> V = ones(3, 1)\n",
      " |      >>> M.col_insert(1, V)\n",
      " |      Matrix([\n",
      " |      [0, 1, 0, 0],\n",
      " |      [0, 1, 0, 0],\n",
      " |      [0, 1, 0, 0]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      col\n",
      " |      row_insert\n",
      " |  \n",
      " |  col_join(self, other)\n",
      " |      Concatenates two matrices along self's last and other's first row.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import zeros, ones\n",
      " |      >>> M = zeros(3)\n",
      " |      >>> V = ones(1, 3)\n",
      " |      >>> M.col_join(V)\n",
      " |      Matrix([\n",
      " |      [0, 0, 0],\n",
      " |      [0, 0, 0],\n",
      " |      [0, 0, 0],\n",
      " |      [1, 1, 1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      col\n",
      " |      row_join\n",
      " |  \n",
      " |  diagonal(self, k=0)\n",
      " |      Returns the kth diagonal of self. The main diagonal\n",
      " |      corresponds to `k=0`; diagonals above and below correspond to\n",
      " |      `k > 0` and `k < 0`, respectively. The values of `self[i, j]`\n",
      " |      for which `j - i = k`, are returned in order of increasing\n",
      " |      `i + j`, starting with `i + j = |k|`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> m = Matrix(3, 3, lambda i, j: j - i); m\n",
      " |      Matrix([\n",
      " |      [ 0,  1, 2],\n",
      " |      [-1,  0, 1],\n",
      " |      [-2, -1, 0]])\n",
      " |      >>> _.diagonal()\n",
      " |      Matrix([[0, 0, 0]])\n",
      " |      >>> m.diagonal(1)\n",
      " |      Matrix([[1, 1]])\n",
      " |      >>> m.diagonal(-2)\n",
      " |      Matrix([[-2]])\n",
      " |      \n",
      " |      Even though the diagonal is returned as a Matrix, the element\n",
      " |      retrieval can be done with a single index:\n",
      " |      \n",
      " |      >>> Matrix.diag(1, 2, 3).diagonal()[1]  # instead of [0, 1]\n",
      " |      2\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      diag - to create a diagonal matrix\n",
      " |  \n",
      " |  extract(self, rowsList, colsList)\n",
      " |      Return a submatrix by specifying a list of rows and columns.\n",
      " |      Negative indices can be given. All indices must be in the range\n",
      " |      $-n \\le i < n$ where $n$ is the number of rows or columns.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> m = Matrix(4, 3, range(12))\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [0,  1,  2],\n",
      " |      [3,  4,  5],\n",
      " |      [6,  7,  8],\n",
      " |      [9, 10, 11]])\n",
      " |      >>> m.extract([0, 1, 3], [0, 1])\n",
      " |      Matrix([\n",
      " |      [0,  1],\n",
      " |      [3,  4],\n",
      " |      [9, 10]])\n",
      " |      \n",
      " |      Rows or columns can be repeated:\n",
      " |      \n",
      " |      >>> m.extract([0, 0, 1], [-1])\n",
      " |      Matrix([\n",
      " |      [2],\n",
      " |      [2],\n",
      " |      [5]])\n",
      " |      \n",
      " |      Every other row can be taken by using range to provide the indices:\n",
      " |      \n",
      " |      >>> m.extract(range(0, m.rows, 2), [-1])\n",
      " |      Matrix([\n",
      " |      [2],\n",
      " |      [8]])\n",
      " |      \n",
      " |      RowsList or colsList can also be a list of booleans, in which case\n",
      " |      the rows or columns corresponding to the True values will be selected:\n",
      " |      \n",
      " |      >>> m.extract([0, 1, 2, 3], [True, False, True])\n",
      " |      Matrix([\n",
      " |      [0,  2],\n",
      " |      [3,  5],\n",
      " |      [6,  8],\n",
      " |      [9, 11]])\n",
      " |  \n",
      " |  get_diag_blocks(self)\n",
      " |      Obtains the square sub-matrices on the main diagonal of a square matrix.\n",
      " |      \n",
      " |      Useful for inverting symbolic matrices or solving systems of\n",
      " |      linear equations which may be decoupled by having a block diagonal\n",
      " |      structure.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> A = Matrix([[1, 3, 0, 0], [y, z*z, 0, 0], [0, 0, x, 0], [0, 0, 0, 0]])\n",
      " |      >>> a1, a2, a3 = A.get_diag_blocks()\n",
      " |      >>> a1\n",
      " |      Matrix([\n",
      " |      [1,    3],\n",
      " |      [y, z**2]])\n",
      " |      >>> a2\n",
      " |      Matrix([[x]])\n",
      " |      >>> a3\n",
      " |      Matrix([[0]])\n",
      " |  \n",
      " |  reshape(self, rows, cols)\n",
      " |      Reshape the matrix. Total number of elements must remain the same.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> m = Matrix(2, 3, lambda i, j: 1)\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 1, 1],\n",
      " |      [1, 1, 1]])\n",
      " |      >>> m.reshape(1, 6)\n",
      " |      Matrix([[1, 1, 1, 1, 1, 1]])\n",
      " |      >>> m.reshape(3, 2)\n",
      " |      Matrix([\n",
      " |      [1, 1],\n",
      " |      [1, 1],\n",
      " |      [1, 1]])\n",
      " |  \n",
      " |  row(self, i)\n",
      " |      Elementary row selector.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import eye\n",
      " |      >>> eye(2).row(0)\n",
      " |      Matrix([[1, 0]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      col\n",
      " |      row_del\n",
      " |      row_join\n",
      " |      row_insert\n",
      " |  \n",
      " |  row_del(self, row)\n",
      " |      Delete the specified row.\n",
      " |  \n",
      " |  row_insert(self, pos, other)\n",
      " |      Insert one or more rows at the given row position.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import zeros, ones\n",
      " |      >>> M = zeros(3)\n",
      " |      >>> V = ones(1, 3)\n",
      " |      >>> M.row_insert(1, V)\n",
      " |      Matrix([\n",
      " |      [0, 0, 0],\n",
      " |      [1, 1, 1],\n",
      " |      [0, 0, 0],\n",
      " |      [0, 0, 0]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      row\n",
      " |      col_insert\n",
      " |  \n",
      " |  row_join(self, other)\n",
      " |      Concatenates two matrices along self's last and rhs's first column\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import zeros, ones\n",
      " |      >>> M = zeros(3)\n",
      " |      >>> V = ones(3, 1)\n",
      " |      >>> M.row_join(V)\n",
      " |      Matrix([\n",
      " |      [0, 0, 0, 1],\n",
      " |      [0, 0, 0, 1],\n",
      " |      [0, 0, 0, 1]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      row\n",
      " |      col_join\n",
      " |  \n",
      " |  todod(M)\n",
      " |      Returns matrix as dict of dicts containing non-zero elements of the Matrix\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> A = Matrix([[0, 1],[0, 3]])\n",
      " |      >>> A\n",
      " |      Matrix([\n",
      " |      [0, 1],\n",
      " |      [0, 3]])\n",
      " |      >>> A.todod()\n",
      " |      {0: {1: 1}, 1: {1: 3}}\n",
      " |  \n",
      " |  todok(self)\n",
      " |      Return the matrix as dictionary of keys.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> M = Matrix.eye(3)\n",
      " |      >>> M.todok()\n",
      " |      {(0, 0): 1, (1, 1): 1, (2, 2): 1}\n",
      " |  \n",
      " |  tolist(self)\n",
      " |      Return the Matrix as a nested Python list.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, ones\n",
      " |      >>> m = Matrix(3, 3, range(9))\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [0, 1, 2],\n",
      " |      [3, 4, 5],\n",
      " |      [6, 7, 8]])\n",
      " |      >>> m.tolist()\n",
      " |      [[0, 1, 2], [3, 4, 5], [6, 7, 8]]\n",
      " |      >>> ones(3, 0).tolist()\n",
      " |      [[], [], []]\n",
      " |      \n",
      " |      When there are no rows then it will not be possible to tell how\n",
      " |      many columns were in the original matrix:\n",
      " |      \n",
      " |      >>> ones(0, 3).tolist()\n",
      " |      []\n",
      " |  \n",
      " |  vec(self)\n",
      " |      Return the Matrix converted into a one column matrix by stacking columns\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> m=Matrix([[1, 3], [2, 4]])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 3],\n",
      " |      [2, 4]])\n",
      " |      >>> m.vec()\n",
      " |      Matrix([\n",
      " |      [1],\n",
      " |      [2],\n",
      " |      [3],\n",
      " |      [4]])\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      vech\n",
      " |  \n",
      " |  vech(self, diagonal=True, check_symmetry=True)\n",
      " |      Reshapes the matrix into a column vector by stacking the\n",
      " |      elements in the lower triangle.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      diagonal : bool, optional\n",
      " |          If ``True``, it includes the diagonal elements.\n",
      " |      \n",
      " |      check_symmetry : bool, optional\n",
      " |          If ``True``, it checks whether the matrix is symmetric.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix\n",
      " |      >>> m=Matrix([[1, 2], [2, 3]])\n",
      " |      >>> m\n",
      " |      Matrix([\n",
      " |      [1, 2],\n",
      " |      [2, 3]])\n",
      " |      >>> m.vech()\n",
      " |      Matrix([\n",
      " |      [1],\n",
      " |      [2],\n",
      " |      [3]])\n",
      " |      >>> m.vech(diagonal=False)\n",
      " |      Matrix([[2]])\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      This should work for symmetric matrices and ``vech`` can\n",
      " |      represent symmetric matrices in vector form with less size than\n",
      " |      ``vec``.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      vec\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.matrices.common.MatrixShaping:\n",
      " |  \n",
      " |  hstack(*args) from builtins.type\n",
      " |      Return a matrix formed by joining args horizontally (i.e.\n",
      " |      by repeated application of row_join).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, eye\n",
      " |      >>> Matrix.hstack(eye(2), 2*eye(2))\n",
      " |      Matrix([\n",
      " |      [1, 0, 2, 0],\n",
      " |      [0, 1, 0, 2]])\n",
      " |  \n",
      " |  vstack(*args) from builtins.type\n",
      " |      Return a matrix formed by joining args vertically (i.e.\n",
      " |      by repeated application of col_join).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Matrix, eye\n",
      " |      >>> Matrix.vstack(eye(2), 2*eye(2))\n",
      " |      Matrix([\n",
      " |      [1, 0],\n",
      " |      [0, 1],\n",
      " |      [2, 0],\n",
      " |      [0, 2]])\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.matrices.common.MatrixShaping:\n",
      " |  \n",
      " |  shape\n",
      " |      The shape (dimensions) of the matrix as the 2-tuple (rows, cols).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import zeros\n",
      " |      >>> M = zeros(2, 3)\n",
      " |      >>> M.shape\n",
      " |      (2, 3)\n",
      " |      >>> M.rows\n",
      " |      2\n",
      " |      >>> M.cols\n",
      " |      3\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from sympy.matrices.common.MatrixRequired:\n",
      " |  \n",
      " |  __dict__\n",
      " |      dictionary for instance variables (if defined)\n",
      " |  \n",
      " |  __weakref__\n",
      " |      list of weak references to the object (if defined)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.matrices.common.MatrixRequired:\n",
      " |  \n",
      " |  cols = None\n",
      " |  \n",
      " |  rows = None\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.printing.defaults.Printable:\n",
      " |  \n",
      " |  __repr__ = __str__(self)\n",
      " |      Return str(self).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(Matrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "id": "40b12f81",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function diag in module sympy.matrices.dense:\n",
      "\n",
      "diag(*values, strict=True, unpack=False, **kwargs)\n",
      "    Returns a matrix with the provided values placed on the\n",
      "    diagonal. If non-square matrices are included, they will\n",
      "    produce a block-diagonal matrix.\n",
      "    \n",
      "    Examples\n",
      "    ========\n",
      "    \n",
      "    This version of diag is a thin wrapper to Matrix.diag that differs\n",
      "    in that it treats all lists like matrices -- even when a single list\n",
      "    is given. If this is not desired, either put a `*` before the list or\n",
      "    set `unpack=True`.\n",
      "    \n",
      "    >>> from sympy import diag\n",
      "    \n",
      "    >>> diag([1, 2, 3], unpack=True)  # = diag(1,2,3) or diag(*[1,2,3])\n",
      "    Matrix([\n",
      "    [1, 0, 0],\n",
      "    [0, 2, 0],\n",
      "    [0, 0, 3]])\n",
      "    \n",
      "    >>> diag([1, 2, 3])  # a column vector\n",
      "    Matrix([\n",
      "    [1],\n",
      "    [2],\n",
      "    [3]])\n",
      "    \n",
      "    See Also\n",
      "    ========\n",
      "    .common.MatrixCommon.eye\n",
      "    .common.MatrixCommon.diagonal - to extract a diagonal\n",
      "    .common.MatrixCommon.diag\n",
      "    .expressions.blockmatrix.BlockMatrix\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(diag)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "cf620ac2",
   "metadata": {},
   "outputs": [],
   "source": [
    "def least_squares_estimate(data_x,data_y):\n",
    "    if len(data_y)!=len(data_x):\n",
    "        raise InputError\n",
    "    else:\n",
    "        n=len(data_x)\n",
    "        average_x=(sum(data_x)/S(n))\n",
    "        average_y=(sum(data_y)/S(n))\n",
    "        A=diag(*data_x)-diag(*[average_x]*n)\n",
    "        B=diag(*data_y)-diag(*[average_y]*n)\n",
    "        cross_xy=sum(A*B)\n",
    "        square_x=sum(A**2)\n",
    "        square_y=sum(B**2)\n",
    "        b=cross_xy/square_x\n",
    "        a=average_y-b*average_x\n",
    "        r=cross_xy/sqrt(square_x*square_y)\n",
    "        print(average_x,average_y,cross_xy, square_x, square_y)\n",
    "        print(\"y=bx+a:r\" , \" b:\" , b , \" a:\",a , \" r:\" ,r)\n",
    "        return [b,a,r]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "id": "3c24a3fb",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "y=bx+a:r  b: 197/1980  a: 3637/396  r: 197*sqrt(286)/3432\n"
     ]
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 9.18434343434343$"
      ],
      "text/plain": [
       "9.18434343434343"
      ]
     },
     "execution_count": 173,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(least_squares_estimate(data_x,data_y)[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "id": "9e4a0c2b",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_x=[3,4,5,6,7]\n",
    "data_y=[45,50,60,65,70]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 180,
   "id": "8c8ce5fe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 58 65 10 430\n",
      "y=bx+a:r  b: 13/2  a: 51/2  r: 13*sqrt(43)/86\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[13/2, 51/2, 13*sqrt(43)/86]"
      ]
     },
     "execution_count": 180,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(least_squares_estimate(data_x,data_y))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "id": "6465e03a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "y=bx+a:r  b: 13/2  a: 51/2  r: 13*sqrt(43)/86\n"
     ]
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 0.99124070716193$"
      ],
      "text/plain": [
       "0.991240707161930"
      ]
     },
     "execution_count": 176,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(least_squares_estimate(data_x,data_y)[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "id": "733a1d25",
   "metadata": {},
   "outputs": [],
   "source": [
    "A=diag(*data_x)-diag(*[(sum(data_x)/S(5))]*5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "id": "abef656e",
   "metadata": {},
   "outputs": [],
   "source": [
    "B=diag(*data_y)-diag(*[(sum(data_y)/S(5))]*5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "id": "8481d8b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 197$"
      ],
      "text/plain": [
       "197"
      ]
     },
     "execution_count": 155,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(A*B)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "id": "5d0485a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 1980$"
      ],
      "text/plain": [
       "1980"
      ]
     },
     "execution_count": 156,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(A**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "id": "538dd950",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 0.0994949494949495$"
      ],
      "text/plain": [
       "0.0994949494949495"
      ]
     },
     "execution_count": 158,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(sum(A*B)/sum(A**2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "id": "0d563ec7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 0.6557438524302$"
      ],
      "text/plain": [
       "0.655743852430200"
      ]
     },
     "execution_count": 177,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sqrt(0.43)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "id": "9254df2c",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 0.207364413533277$"
      ],
      "text/plain": [
       "0.207364413533277"
      ]
     },
     "execution_count": 178,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sqrt(0.043)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 181,
   "id": "7c3f7253",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.2051282051282053"
      ]
     },
     "execution_count": 181,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "500*(240*30-210*20)**2/(260*240*450*50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 182,
   "id": "5ed92a5f",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_x=[21,23,25,27]\n",
    "data_y=[15,18,19,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "id": "34468a7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "24 18 16 20 14\n",
      "y=bx+a:r  b: 4/5  a: -6/5  r: 4*sqrt(70)/35\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[4/5, -6/5, 4*sqrt(70)/35]"
      ]
     },
     "execution_count": 184,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "least_squares_estimate(data_x,data_y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "id": "efdbcac6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "145.97"
      ]
     },
     "execution_count": 185,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "6.635*22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 186,
   "id": "16ce97ef",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_x=[1,2,3,4,5,6]\n",
    "data_y=[53,45,39,40,36,33]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "id": "f078b0e7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7/2 41 -63 35/2 254\n",
      "y=bx+a:r  b: -18/5  a: 268/5  r: -9*sqrt(4445)/635\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[-18/5, 268/5, -9*sqrt(4445)/635]"
      ]
     },
     "execution_count": 187,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "least_squares_estimate(data_x,data_y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "id": "7f925ff9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.594405594405594"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "800/143"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "id": "ecc8eb84",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function function_range in module sympy.calculus.util:\n",
      "\n",
      "function_range(f, symbol, domain)\n",
      "    Finds the range of a function in a given domain.\n",
      "    This method is limited by the ability to determine the singularities and\n",
      "    determine limits.\n",
      "    \n",
      "    Parameters\n",
      "    ==========\n",
      "    \n",
      "    f : :py:class:`~.Expr`\n",
      "        The concerned function.\n",
      "    symbol : :py:class:`~.Symbol`\n",
      "        The variable for which the range of function is to be determined.\n",
      "    domain : :py:class:`~.Interval`\n",
      "        The domain under which the range of the function has to be found.\n",
      "    \n",
      "    Examples\n",
      "    ========\n",
      "    \n",
      "    >>> from sympy import Interval, Symbol, S, exp, log, pi, sqrt, sin, tan\n",
      "    >>> from sympy.calculus.util import function_range\n",
      "    >>> x = Symbol('x')\n",
      "    >>> function_range(sin(x), x, Interval(0, 2*pi))\n",
      "    Interval(-1, 1)\n",
      "    >>> function_range(tan(x), x, Interval(-pi/2, pi/2))\n",
      "    Interval(-oo, oo)\n",
      "    >>> function_range(1/x, x, S.Reals)\n",
      "    Union(Interval.open(-oo, 0), Interval.open(0, oo))\n",
      "    >>> function_range(exp(x), x, S.Reals)\n",
      "    Interval.open(0, oo)\n",
      "    >>> function_range(log(x), x, S.Reals)\n",
      "    Interval(-oo, oo)\n",
      "    >>> function_range(sqrt(x), x, Interval(-5, 9))\n",
      "    Interval(0, 3)\n",
      "    \n",
      "    Returns\n",
      "    =======\n",
      "    \n",
      "    :py:class:`~.Interval`\n",
      "        Union of all ranges for all intervals under domain where function is\n",
      "        continuous.\n",
      "    \n",
      "    Raises\n",
      "    ======\n",
      "    \n",
      "    NotImplementedError\n",
      "        If any of the intervals, in the given domain, for which function\n",
      "        is continuous are not finite or real,\n",
      "        OR if the critical points of the function on the domain cannot be found.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(function_range)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 190,
   "id": "b0c465a2",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function linsolve in module sympy.solvers.solveset:\n",
      "\n",
      "linsolve(system, *symbols)\n",
      "    Solve system of $N$ linear equations with $M$ variables; both\n",
      "    underdetermined and overdetermined systems are supported.\n",
      "    The possible number of solutions is zero, one or infinite.\n",
      "    Zero solutions throws a ValueError, whereas infinite\n",
      "    solutions are represented parametrically in terms of the given\n",
      "    symbols. For unique solution a :class:`~.FiniteSet` of ordered tuples\n",
      "    is returned.\n",
      "    \n",
      "    All standard input formats are supported:\n",
      "    For the given set of equations, the respective input types\n",
      "    are given below:\n",
      "    \n",
      "    .. math:: 3x + 2y -   z = 1\n",
      "    .. math:: 2x - 2y + 4z = -2\n",
      "    .. math:: 2x -   y + 2z = 0\n",
      "    \n",
      "    * Augmented matrix form, ``system`` given below:\n",
      "    \n",
      "    $$ \\text{system} = \\left[{array}{cccc}\n",
      "        3 &  2 & -1 &  1\\\\\n",
      "        2 & -2 &  4 & -2\\\\\n",
      "        2 & -1 &  2 &  0\n",
      "        \\end{array}\\right] $$\n",
      "    \n",
      "    ::\n",
      "    \n",
      "        system = Matrix([[3, 2, -1, 1], [2, -2, 4, -2], [2, -1, 2, 0]])\n",
      "    \n",
      "    * List of equations form\n",
      "    \n",
      "    ::\n",
      "    \n",
      "        system  =  [3x + 2y - z - 1, 2x - 2y + 4z + 2, 2x - y + 2z]\n",
      "    \n",
      "    * Input $A$ and $b$ in matrix form (from $Ax = b$) are given as:\n",
      "    \n",
      "    $$ A = \\left[\\begin{array}{ccc}\n",
      "        3 &  2 & -1 \\\\\n",
      "        2 & -2 &  4 \\\\\n",
      "        2 & -1 &  2\n",
      "        \\end{array}\\right] \\ \\  b = \\left[\\begin{array}{c}\n",
      "        1 \\\\ -2 \\\\ 0\n",
      "        \\end{array}\\right] $$\n",
      "    \n",
      "    ::\n",
      "    \n",
      "        A = Matrix([[3, 2, -1], [2, -2, 4], [2, -1, 2]])\n",
      "        b = Matrix([[1], [-2], [0]])\n",
      "        system = (A, b)\n",
      "    \n",
      "    Symbols can always be passed but are actually only needed\n",
      "    when 1) a system of equations is being passed and 2) the\n",
      "    system is passed as an underdetermined matrix and one wants\n",
      "    to control the name of the free variables in the result.\n",
      "    An error is raised if no symbols are used for case 1, but if\n",
      "    no symbols are provided for case 2, internally generated symbols\n",
      "    will be provided. When providing symbols for case 2, there should\n",
      "    be at least as many symbols are there are columns in matrix A.\n",
      "    \n",
      "    The algorithm used here is Gauss-Jordan elimination, which\n",
      "    results, after elimination, in a row echelon form matrix.\n",
      "    \n",
      "    Returns\n",
      "    =======\n",
      "    \n",
      "    A FiniteSet containing an ordered tuple of values for the\n",
      "    unknowns for which the `system` has a solution. (Wrapping\n",
      "    the tuple in FiniteSet is used to maintain a consistent\n",
      "    output format throughout solveset.)\n",
      "    \n",
      "    Returns EmptySet, if the linear system is inconsistent.\n",
      "    \n",
      "    Raises\n",
      "    ======\n",
      "    \n",
      "    ValueError\n",
      "        The input is not valid.\n",
      "        The symbols are not given.\n",
      "    \n",
      "    Examples\n",
      "    ========\n",
      "    \n",
      "    >>> from sympy import Matrix, linsolve, symbols\n",
      "    >>> x, y, z = symbols(\"x, y, z\")\n",
      "    >>> A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 10]])\n",
      "    >>> b = Matrix([3, 6, 9])\n",
      "    >>> A\n",
      "    Matrix([\n",
      "    [1, 2,  3],\n",
      "    [4, 5,  6],\n",
      "    [7, 8, 10]])\n",
      "    >>> b\n",
      "    Matrix([\n",
      "    [3],\n",
      "    [6],\n",
      "    [9]])\n",
      "    >>> linsolve((A, b), [x, y, z])\n",
      "    {(-1, 2, 0)}\n",
      "    \n",
      "    * Parametric Solution: In case the system is underdetermined, the\n",
      "      function will return a parametric solution in terms of the given\n",
      "      symbols. Those that are free will be returned unchanged. e.g. in\n",
      "      the system below, `z` is returned as the solution for variable z;\n",
      "      it can take on any value.\n",
      "    \n",
      "    >>> A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n",
      "    >>> b = Matrix([3, 6, 9])\n",
      "    >>> linsolve((A, b), x, y, z)\n",
      "    {(z - 1, 2 - 2*z, z)}\n",
      "    \n",
      "    If no symbols are given, internally generated symbols will be used.\n",
      "    The ``tau0`` in the third position indicates (as before) that the third\n",
      "    variable -- whatever it is named -- can take on any value:\n",
      "    \n",
      "    >>> linsolve((A, b))\n",
      "    {(tau0 - 1, 2 - 2*tau0, tau0)}\n",
      "    \n",
      "    * List of equations as input\n",
      "    \n",
      "    >>> Eqns = [3*x + 2*y - z - 1, 2*x - 2*y + 4*z + 2, - x + y/2 - z]\n",
      "    >>> linsolve(Eqns, x, y, z)\n",
      "    {(1, -2, -2)}\n",
      "    \n",
      "    * Augmented matrix as input\n",
      "    \n",
      "    >>> aug = Matrix([[2, 1, 3, 1], [2, 6, 8, 3], [6, 8, 18, 5]])\n",
      "    >>> aug\n",
      "    Matrix([\n",
      "    [2, 1,  3, 1],\n",
      "    [2, 6,  8, 3],\n",
      "    [6, 8, 18, 5]])\n",
      "    >>> linsolve(aug, x, y, z)\n",
      "    {(3/10, 2/5, 0)}\n",
      "    \n",
      "    * Solve for symbolic coefficients\n",
      "    \n",
      "    >>> a, b, c, d, e, f = symbols('a, b, c, d, e, f')\n",
      "    >>> eqns = [a*x + b*y - c, d*x + e*y - f]\n",
      "    >>> linsolve(eqns, x, y)\n",
      "    {((-b*f + c*e)/(a*e - b*d), (a*f - c*d)/(a*e - b*d))}\n",
      "    \n",
      "    * A degenerate system returns solution as set of given\n",
      "      symbols.\n",
      "    \n",
      "    >>> system = Matrix(([0, 0, 0], [0, 0, 0], [0, 0, 0]))\n",
      "    >>> linsolve(system, x, y)\n",
      "    {(x, y)}\n",
      "    \n",
      "    * For an empty system linsolve returns empty set\n",
      "    \n",
      "    >>> linsolve([], x)\n",
      "    EmptySet\n",
      "    \n",
      "    * An error is raised if, after expansion, any nonlinearity\n",
      "      is detected:\n",
      "    \n",
      "    >>> linsolve([x*(1/x - 1), (y - 1)**2 - y**2 + 1], x, y)\n",
      "    {(1, 1)}\n",
      "    >>> linsolve([x**2 - 1], x)\n",
      "    Traceback (most recent call last):\n",
      "    ...\n",
      "    NonlinearError:\n",
      "    nonlinear term encountered: x**2\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(linsolve)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 191,
   "id": "0f520fdf",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [
    {
     "ename": "NonlinearError",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mPolyNonlinearError\u001b[0m                        Traceback (most recent call last)",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/polys/matrices/linsolve.py:153\u001b[0m, in \u001b[0;36m_linear_eq_to_dict\u001b[0;34m(eqs, syms)\u001b[0m\n\u001b[1;32m    152\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 153\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_linear_eq_to_dict_inner\u001b[49m\u001b[43m(\u001b[49m\u001b[43meqs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msyms\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    154\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m PolyNonlinearError:\n\u001b[1;32m    155\u001b[0m     \u001b[38;5;66;03m# XXX: This should be deprecated:\u001b[39;00m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/polys/matrices/linsolve.py:165\u001b[0m, in \u001b[0;36m_linear_eq_to_dict_inner\u001b[0;34m(eqs, syms)\u001b[0m\n\u001b[1;32m    164\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m eq \u001b[38;5;129;01min\u001b[39;00m eqs:\n\u001b[0;32m--> 165\u001b[0m     rhs, eqdict \u001b[38;5;241m=\u001b[39m \u001b[43m_lin_eq2dict\u001b[49m\u001b[43m(\u001b[49m\u001b[43meq\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msyms\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    166\u001b[0m     eqsdict\u001b[38;5;241m.\u001b[39mappend(eqdict)\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/polys/matrices/linsolve.py:209\u001b[0m, in \u001b[0;36m_lin_eq2dict\u001b[0;34m(a, symset)\u001b[0m\n\u001b[1;32m    208\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 209\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m PolyNonlinearError\n",
      "\u001b[0;31mPolyNonlinearError\u001b[0m: ",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[0;31mPolyNonlinearError\u001b[0m                        Traceback (most recent call last)",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/solvers/solveset.py:2794\u001b[0m, in \u001b[0;36mlinsolve\u001b[0;34m(system, *symbols)\u001b[0m\n\u001b[1;32m   2793\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 2794\u001b[0m     sol \u001b[38;5;241m=\u001b[39m \u001b[43m_linsolve\u001b[49m\u001b[43m(\u001b[49m\u001b[43meqs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msymbols\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   2795\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m PolyNonlinearError \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m   2796\u001b[0m     \u001b[38;5;66;03m# e.g. cos(x) contains an element of the set of generators\u001b[39;00m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/polys/matrices/linsolve.py:72\u001b[0m, in \u001b[0;36m_linsolve\u001b[0;34m(eqs, syms)\u001b[0m\n\u001b[1;32m     71\u001b[0m \u001b[38;5;66;03m# Convert to sparse augmented matrix (len(eqs) x (nsyms+1))\u001b[39;00m\n\u001b[0;32m---> 72\u001b[0m eqsdict, rhs \u001b[38;5;241m=\u001b[39m \u001b[43m_linear_eq_to_dict\u001b[49m\u001b[43m(\u001b[49m\u001b[43meqs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msyms\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m     73\u001b[0m Aaug \u001b[38;5;241m=\u001b[39m sympy_dict_to_dm(eqsdict, rhs, syms)\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/polys/matrices/linsolve.py:157\u001b[0m, in \u001b[0;36m_linear_eq_to_dict\u001b[0;34m(eqs, syms)\u001b[0m\n\u001b[1;32m    156\u001b[0m eqs \u001b[38;5;241m=\u001b[39m _expand_eqs_deprecated(eqs)\n\u001b[0;32m--> 157\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_linear_eq_to_dict_inner\u001b[49m\u001b[43m(\u001b[49m\u001b[43meqs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msyms\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/polys/matrices/linsolve.py:165\u001b[0m, in \u001b[0;36m_linear_eq_to_dict_inner\u001b[0;34m(eqs, syms)\u001b[0m\n\u001b[1;32m    164\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m eq \u001b[38;5;129;01min\u001b[39;00m eqs:\n\u001b[0;32m--> 165\u001b[0m     rhs, eqdict \u001b[38;5;241m=\u001b[39m \u001b[43m_lin_eq2dict\u001b[49m\u001b[43m(\u001b[49m\u001b[43meq\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msyms\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    166\u001b[0m     eqsdict\u001b[38;5;241m.\u001b[39mappend(eqdict)\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/polys/matrices/linsolve.py:209\u001b[0m, in \u001b[0;36m_lin_eq2dict\u001b[0;34m(a, symset)\u001b[0m\n\u001b[1;32m    208\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 209\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m PolyNonlinearError\n",
      "\u001b[0;31mPolyNonlinearError\u001b[0m: ",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[0;31mNonlinearError\u001b[0m                            Traceback (most recent call last)",
      "Input \u001b[0;32mIn [191]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mlinsolve\u001b[49m\u001b[43m(\u001b[49m\u001b[43m[\u001b[49m\u001b[43mx\u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43my\u001b[49m\u001b[38;5;241;43m>\u001b[39;49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43mx\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43my\u001b[49m\u001b[38;5;241;43m<\u001b[39;49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[38;5;241;43m<\u001b[39;49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43my\u001b[49m\u001b[43m,\u001b[49m\u001b[43my\u001b[49m\u001b[38;5;241;43m<\u001b[39;49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mk\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m[\u001b[49m\u001b[43mx\u001b[49m\u001b[43m,\u001b[49m\u001b[43my\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/solvers/solveset.py:2797\u001b[0m, in \u001b[0;36mlinsolve\u001b[0;34m(system, *symbols)\u001b[0m\n\u001b[1;32m   2794\u001b[0m     sol \u001b[38;5;241m=\u001b[39m _linsolve(eqs, symbols)\n\u001b[1;32m   2795\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m PolyNonlinearError \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m   2796\u001b[0m     \u001b[38;5;66;03m# e.g. cos(x) contains an element of the set of generators\u001b[39;00m\n\u001b[0;32m-> 2797\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m NonlinearError(\u001b[38;5;28mstr\u001b[39m(exc))\n\u001b[1;32m   2799\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m sol \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m   2800\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m S\u001b[38;5;241m.\u001b[39mEmptySet\n",
      "\u001b[0;31mNonlinearError\u001b[0m: "
     ]
    }
   ],
   "source": [
    "linsolve([x+2*y>=0,x-y<=0,0<=y,y<=k],[x,y])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "09b3e118",
   "metadata": {
    "collapsed": true,
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class Poly in module sympy.polys.polytools:\n",
      "\n",
      "class Poly(sympy.core.basic.Basic)\n",
      " |  Poly(rep, *gens, **args)\n",
      " |  \n",
      " |  Generic class for representing and operating on polynomial expressions.\n",
      " |  \n",
      " |  See :ref:`polys-docs` for general documentation.\n",
      " |  \n",
      " |  Poly is a subclass of Basic rather than Expr but instances can be\n",
      " |  converted to Expr with the :py:meth:`~.Poly.as_expr` method.\n",
      " |  \n",
      " |  .. deprecated:: 1.6\n",
      " |  \n",
      " |     Combining Poly with non-Poly objects in binary operations is\n",
      " |     deprecated. Explicitly convert both objects to either Poly or Expr\n",
      " |     first. See :ref:`deprecated-poly-nonpoly-binary-operations`.\n",
      " |  \n",
      " |  Examples\n",
      " |  ========\n",
      " |  \n",
      " |  >>> from sympy import Poly\n",
      " |  >>> from sympy.abc import x, y\n",
      " |  \n",
      " |  Create a univariate polynomial:\n",
      " |  \n",
      " |  >>> Poly(x*(x**2 + x - 1)**2)\n",
      " |  Poly(x**5 + 2*x**4 - x**3 - 2*x**2 + x, x, domain='ZZ')\n",
      " |  \n",
      " |  Create a univariate polynomial with specific domain:\n",
      " |  \n",
      " |  >>> from sympy import sqrt\n",
      " |  >>> Poly(x**2 + 2*x + sqrt(3), domain='R')\n",
      " |  Poly(1.0*x**2 + 2.0*x + 1.73205080756888, x, domain='RR')\n",
      " |  \n",
      " |  Create a multivariate polynomial:\n",
      " |  \n",
      " |  >>> Poly(y*x**2 + x*y + 1)\n",
      " |  Poly(x**2*y + x*y + 1, x, y, domain='ZZ')\n",
      " |  \n",
      " |  Create a univariate polynomial, where y is a constant:\n",
      " |  \n",
      " |  >>> Poly(y*x**2 + x*y + 1,x)\n",
      " |  Poly(y*x**2 + y*x + 1, x, domain='ZZ[y]')\n",
      " |  \n",
      " |  You can evaluate the above polynomial as a function of y:\n",
      " |  \n",
      " |  >>> Poly(y*x**2 + x*y + 1,x).eval(2)\n",
      " |  6*y + 1\n",
      " |  \n",
      " |  See Also\n",
      " |  ========\n",
      " |  \n",
      " |  sympy.core.expr.Expr\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      Poly\n",
      " |      sympy.core.basic.Basic\n",
      " |      sympy.printing.defaults.Printable\n",
      " |      builtins.object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  EC(f, order=None)\n",
      " |      Returns the last non-zero coefficient of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**3 + 2*x**2 + 3*x, x).EC()\n",
      " |      3\n",
      " |  \n",
      " |  EM(f, order=None)\n",
      " |      Returns the last non-zero monomial of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(4*x**2 + 2*x*y**2 + x*y + 3*y, x, y).EM()\n",
      " |      x**0*y**1\n",
      " |  \n",
      " |  ET(f, order=None)\n",
      " |      Returns the last non-zero term of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(4*x**2 + 2*x*y**2 + x*y + 3*y, x, y).ET()\n",
      " |      (x**0*y**1, 3)\n",
      " |  \n",
      " |  LC(f, order=None)\n",
      " |      Returns the leading coefficient of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(4*x**3 + 2*x**2 + 3*x, x).LC()\n",
      " |      4\n",
      " |  \n",
      " |  LM(f, order=None)\n",
      " |      Returns the leading monomial of ``f``.\n",
      " |      \n",
      " |      The Leading monomial signifies the monomial having\n",
      " |      the highest power of the principal generator in the\n",
      " |      expression f.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(4*x**2 + 2*x*y**2 + x*y + 3*y, x, y).LM()\n",
      " |      x**2*y**0\n",
      " |  \n",
      " |  LT(f, order=None)\n",
      " |      Returns the leading term of ``f``.\n",
      " |      \n",
      " |      The Leading term signifies the term having\n",
      " |      the highest power of the principal generator in the\n",
      " |      expression f along with its coefficient.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(4*x**2 + 2*x*y**2 + x*y + 3*y, x, y).LT()\n",
      " |      (x**2*y**0, 4)\n",
      " |  \n",
      " |  TC(f)\n",
      " |      Returns the trailing coefficient of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**3 + 2*x**2 + 3*x, x).TC()\n",
      " |      0\n",
      " |  \n",
      " |  __abs__(f)\n",
      " |  \n",
      " |  __add__(f, g)\n",
      " |  \n",
      " |  __bool__(f)\n",
      " |  \n",
      " |  __call__(f, *values)\n",
      " |      Evaluate ``f`` at the give values.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> f = Poly(2*x*y + 3*x + y + 2*z, x, y, z)\n",
      " |      \n",
      " |      >>> f(2)\n",
      " |      Poly(5*y + 2*z + 6, y, z, domain='ZZ')\n",
      " |      >>> f(2, 5)\n",
      " |      Poly(2*z + 31, z, domain='ZZ')\n",
      " |      >>> f(2, 5, 7)\n",
      " |      45\n",
      " |  \n",
      " |  __divmod__(f, g)\n",
      " |  \n",
      " |  __eq__(self, other)\n",
      " |      Return a boolean indicating whether a == b on the basis of\n",
      " |      their symbolic trees.\n",
      " |      \n",
      " |      This is the same as a.compare(b) == 0 but faster.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      If a class that overrides __eq__() needs to retain the\n",
      " |      implementation of __hash__() from a parent class, the\n",
      " |      interpreter must be told this explicitly by setting\n",
      " |      __hash__ : Callable[[object], int] = <ParentClass>.__hash__.\n",
      " |      Otherwise the inheritance of __hash__() will be blocked,\n",
      " |      just as if __hash__ had been explicitly set to None.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      from http://docs.python.org/dev/reference/datamodel.html#object.__hash__\n",
      " |  \n",
      " |  __floordiv__(f, g)\n",
      " |  \n",
      " |  __hash__(self)\n",
      " |      Return hash(self).\n",
      " |  \n",
      " |  __mod__(f, g)\n",
      " |  \n",
      " |  __mul__(f, g)\n",
      " |  \n",
      " |  __ne__(f, g)\n",
      " |      ``a != b``  -> Compare two symbolic trees and see whether they are different\n",
      " |      \n",
      " |      this is the same as:\n",
      " |      \n",
      " |      ``a.compare(b) != 0``\n",
      " |      \n",
      " |      but faster\n",
      " |  \n",
      " |  __neg__(f)\n",
      " |  \n",
      " |  __pow__(f, n)\n",
      " |  \n",
      " |  __radd__(f, g)\n",
      " |  \n",
      " |  __rdivmod__(f, g)\n",
      " |  \n",
      " |  __rfloordiv__(f, g)\n",
      " |  \n",
      " |  __rmod__(f, g)\n",
      " |  \n",
      " |  __rmul__(f, g)\n",
      " |  \n",
      " |  __rsub__(f, g)\n",
      " |  \n",
      " |  __rtruediv__(f, g)\n",
      " |  \n",
      " |  __sub__(f, g)\n",
      " |  \n",
      " |  __truediv__(f, g)\n",
      " |  \n",
      " |  abs(f)\n",
      " |      Make all coefficients in ``f`` positive.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).abs()\n",
      " |      Poly(x**2 + 1, x, domain='ZZ')\n",
      " |  \n",
      " |  add(f, g)\n",
      " |      Add two polynomials ``f`` and ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).add(Poly(x - 2, x))\n",
      " |      Poly(x**2 + x - 1, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x) + Poly(x - 2, x)\n",
      " |      Poly(x**2 + x - 1, x, domain='ZZ')\n",
      " |  \n",
      " |  add_ground(f, coeff)\n",
      " |      Add an element of the ground domain to ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x + 1).add_ground(2)\n",
      " |      Poly(x + 3, x, domain='ZZ')\n",
      " |  \n",
      " |  all_coeffs(f)\n",
      " |      Returns all coefficients from a univariate polynomial ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**3 + 2*x - 1, x).all_coeffs()\n",
      " |      [1, 0, 2, -1]\n",
      " |  \n",
      " |  all_monoms(f)\n",
      " |      Returns all monomials from a univariate polynomial ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**3 + 2*x - 1, x).all_monoms()\n",
      " |      [(3,), (2,), (1,), (0,)]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      all_terms\n",
      " |  \n",
      " |  all_roots(f, multiple=True, radicals=True)\n",
      " |      Return a list of real and complex roots with multiplicities.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(2*x**3 - 7*x**2 + 4*x + 4).all_roots()\n",
      " |      [-1/2, 2, 2]\n",
      " |      >>> Poly(x**3 + x + 1).all_roots()\n",
      " |      [CRootOf(x**3 + x + 1, 0),\n",
      " |       CRootOf(x**3 + x + 1, 1),\n",
      " |       CRootOf(x**3 + x + 1, 2)]\n",
      " |  \n",
      " |  all_terms(f)\n",
      " |      Returns all terms from a univariate polynomial ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**3 + 2*x - 1, x).all_terms()\n",
      " |      [((3,), 1), ((2,), 0), ((1,), 2), ((0,), -1)]\n",
      " |  \n",
      " |  as_dict(f, native=False, zero=False)\n",
      " |      Switch to a ``dict`` representation.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + 2*x*y**2 - y, x, y).as_dict()\n",
      " |      {(0, 1): -1, (1, 2): 2, (2, 0): 1}\n",
      " |  \n",
      " |  as_expr(f, *gens)\n",
      " |      Convert a Poly instance to an Expr instance.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> f = Poly(x**2 + 2*x*y**2 - y, x, y)\n",
      " |      \n",
      " |      >>> f.as_expr()\n",
      " |      x**2 + 2*x*y**2 - y\n",
      " |      >>> f.as_expr({x: 5})\n",
      " |      10*y**2 - y + 25\n",
      " |      >>> f.as_expr(5, 6)\n",
      " |      379\n",
      " |  \n",
      " |  as_list(f, native=False)\n",
      " |      Switch to a ``list`` representation.\n",
      " |  \n",
      " |  as_poly(self, *gens, **args)\n",
      " |      Converts ``self`` to a polynomial or returns ``None``.\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> print((x**2 + x*y).as_poly())\n",
      " |      Poly(x**2 + x*y, x, y, domain='ZZ')\n",
      " |      \n",
      " |      >>> print((x**2 + x*y).as_poly(x, y))\n",
      " |      Poly(x**2 + x*y, x, y, domain='ZZ')\n",
      " |      \n",
      " |      >>> print((x**2 + sin(y)).as_poly(x, y))\n",
      " |      None\n",
      " |  \n",
      " |  cancel(f, g, include=False)\n",
      " |      Cancel common factors in a rational function ``f/g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(2*x**2 - 2, x).cancel(Poly(x**2 - 2*x + 1, x))\n",
      " |      (1, Poly(2*x + 2, x, domain='ZZ'), Poly(x - 1, x, domain='ZZ'))\n",
      " |      \n",
      " |      >>> Poly(2*x**2 - 2, x).cancel(Poly(x**2 - 2*x + 1, x), include=True)\n",
      " |      (Poly(2*x + 2, x, domain='ZZ'), Poly(x - 1, x, domain='ZZ'))\n",
      " |  \n",
      " |  clear_denoms(self, convert=False)\n",
      " |      Clear denominators, but keep the ground domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, S, QQ\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = Poly(x/2 + S(1)/3, x, domain=QQ)\n",
      " |      \n",
      " |      >>> f.clear_denoms()\n",
      " |      (6, Poly(3*x + 2, x, domain='QQ'))\n",
      " |      >>> f.clear_denoms(convert=True)\n",
      " |      (6, Poly(3*x + 2, x, domain='ZZ'))\n",
      " |  \n",
      " |  coeff(f, x, n=1, right=False)\n",
      " |  \n",
      " |  coeff_monomial(f, monom)\n",
      " |      Returns the coefficient of ``monom`` in ``f`` if there, else None.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, exp\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> p = Poly(24*x*y*exp(8) + 23*x, x, y)\n",
      " |      \n",
      " |      >>> p.coeff_monomial(x)\n",
      " |      23\n",
      " |      >>> p.coeff_monomial(y)\n",
      " |      0\n",
      " |      >>> p.coeff_monomial(x*y)\n",
      " |      24*exp(8)\n",
      " |      \n",
      " |      Note that ``Expr.coeff()`` behaves differently, collecting terms\n",
      " |      if possible; the Poly must be converted to an Expr to use that\n",
      " |      method, however:\n",
      " |      \n",
      " |      >>> p.as_expr().coeff(x)\n",
      " |      24*y*exp(8) + 23\n",
      " |      >>> p.as_expr().coeff(y)\n",
      " |      24*x*exp(8)\n",
      " |      >>> p.as_expr().coeff(x*y)\n",
      " |      24*exp(8)\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      nth: more efficient query using exponents of the monomial's generators\n",
      " |  \n",
      " |  coeffs(f, order=None)\n",
      " |      Returns all non-zero coefficients from ``f`` in lex order.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**3 + 2*x + 3, x).coeffs()\n",
      " |      [1, 2, 3]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      all_coeffs\n",
      " |      coeff_monomial\n",
      " |      nth\n",
      " |  \n",
      " |  cofactors(f, g)\n",
      " |      Returns the GCD of ``f`` and ``g`` and their cofactors.\n",
      " |      \n",
      " |      Returns polynomials ``(h, cff, cfg)`` such that ``h = gcd(f, g)``, and\n",
      " |      ``cff = quo(f, h)`` and ``cfg = quo(g, h)`` are, so called, cofactors\n",
      " |      of ``f`` and ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).cofactors(Poly(x**2 - 3*x + 2, x))\n",
      " |      (Poly(x - 1, x, domain='ZZ'),\n",
      " |       Poly(x + 1, x, domain='ZZ'),\n",
      " |       Poly(x - 2, x, domain='ZZ'))\n",
      " |  \n",
      " |  compose(f, g)\n",
      " |      Computes the functional composition of ``f`` and ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + x, x).compose(Poly(x - 1, x))\n",
      " |      Poly(x**2 - x, x, domain='ZZ')\n",
      " |  \n",
      " |  content(f)\n",
      " |      Returns the GCD of polynomial coefficients.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(6*x**2 + 8*x + 12, x).content()\n",
      " |      2\n",
      " |  \n",
      " |  count_roots(f, inf=None, sup=None)\n",
      " |      Return the number of roots of ``f`` in ``[inf, sup]`` interval.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, I\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**4 - 4, x).count_roots(-3, 3)\n",
      " |      2\n",
      " |      >>> Poly(x**4 - 4, x).count_roots(0, 1 + 3*I)\n",
      " |      1\n",
      " |  \n",
      " |  decompose(f)\n",
      " |      Computes a functional decomposition of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**4 + 2*x**3 - x - 1, x, domain='ZZ').decompose()\n",
      " |      [Poly(x**2 - x - 1, x, domain='ZZ'), Poly(x**2 + x, x, domain='ZZ')]\n",
      " |  \n",
      " |  deflate(f)\n",
      " |      Reduce degree of ``f`` by mapping ``x_i**m`` to ``y_i``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**6*y**2 + x**3 + 1, x, y).deflate()\n",
      " |      ((3, 2), Poly(x**2*y + x + 1, x, y, domain='ZZ'))\n",
      " |  \n",
      " |  degree(f, gen=0)\n",
      " |      Returns degree of ``f`` in ``x_j``.\n",
      " |      \n",
      " |      The degree of 0 is negative infinity.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + y*x + 1, x, y).degree()\n",
      " |      2\n",
      " |      >>> Poly(x**2 + y*x + y, x, y).degree(y)\n",
      " |      1\n",
      " |      >>> Poly(0, x).degree()\n",
      " |      -oo\n",
      " |  \n",
      " |  degree_list(f)\n",
      " |      Returns a list of degrees of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + y*x + 1, x, y).degree_list()\n",
      " |      (2, 1)\n",
      " |  \n",
      " |  diff(f, *specs, **kwargs)\n",
      " |      Computes partial derivative of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + 2*x + 1, x).diff()\n",
      " |      Poly(2*x + 2, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x*y**2 + x, x, y).diff((0, 0), (1, 1))\n",
      " |      Poly(2*x*y, x, y, domain='ZZ')\n",
      " |  \n",
      " |  discriminant(f)\n",
      " |      Computes the discriminant of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 2*x + 3, x).discriminant()\n",
      " |      -8\n",
      " |  \n",
      " |  dispersion(f, g=None)\n",
      " |      Compute the *dispersion* of polynomials.\n",
      " |      \n",
      " |      For two polynomials `f(x)` and `g(x)` with `\\deg f > 0`\n",
      " |      and `\\deg g > 0` the dispersion `\\operatorname{dis}(f, g)` is defined as:\n",
      " |      \n",
      " |      .. math::\n",
      " |          \\operatorname{dis}(f, g)\n",
      " |          & := \\max\\{ J(f,g) \\cup \\{0\\} \\} \\\\\n",
      " |          &  = \\max\\{ \\{a \\in \\mathbb{N} | \\gcd(f(x), g(x+a)) \\neq 1\\} \\cup \\{0\\} \\}\n",
      " |      \n",
      " |      and for a single polynomial `\\operatorname{dis}(f) := \\operatorname{dis}(f, f)`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import poly\n",
      " |      >>> from sympy.polys.dispersion import dispersion, dispersionset\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      Dispersion set and dispersion of a simple polynomial:\n",
      " |      \n",
      " |      >>> fp = poly((x - 3)*(x + 3), x)\n",
      " |      >>> sorted(dispersionset(fp))\n",
      " |      [0, 6]\n",
      " |      >>> dispersion(fp)\n",
      " |      6\n",
      " |      \n",
      " |      Note that the definition of the dispersion is not symmetric:\n",
      " |      \n",
      " |      >>> fp = poly(x**4 - 3*x**2 + 1, x)\n",
      " |      >>> gp = fp.shift(-3)\n",
      " |      >>> sorted(dispersionset(fp, gp))\n",
      " |      [2, 3, 4]\n",
      " |      >>> dispersion(fp, gp)\n",
      " |      4\n",
      " |      >>> sorted(dispersionset(gp, fp))\n",
      " |      []\n",
      " |      >>> dispersion(gp, fp)\n",
      " |      -oo\n",
      " |      \n",
      " |      Computing the dispersion also works over field extensions:\n",
      " |      \n",
      " |      >>> from sympy import sqrt\n",
      " |      >>> fp = poly(x**2 + sqrt(5)*x - 1, x, domain='QQ<sqrt(5)>')\n",
      " |      >>> gp = poly(x**2 + (2 + sqrt(5))*x + sqrt(5), x, domain='QQ<sqrt(5)>')\n",
      " |      >>> sorted(dispersionset(fp, gp))\n",
      " |      [2]\n",
      " |      >>> sorted(dispersionset(gp, fp))\n",
      " |      [1, 4]\n",
      " |      \n",
      " |      We can even perform the computations for polynomials\n",
      " |      having symbolic coefficients:\n",
      " |      \n",
      " |      >>> from sympy.abc import a\n",
      " |      >>> fp = poly(4*x**4 + (4*a + 8)*x**3 + (a**2 + 6*a + 4)*x**2 + (a**2 + 2*a)*x, x)\n",
      " |      >>> sorted(dispersionset(fp))\n",
      " |      [0, 1]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      dispersionset\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      1. [ManWright94]_\n",
      " |      2. [Koepf98]_\n",
      " |      3. [Abramov71]_\n",
      " |      4. [Man93]_\n",
      " |  \n",
      " |  dispersionset(f, g=None)\n",
      " |      Compute the *dispersion set* of two polynomials.\n",
      " |      \n",
      " |      For two polynomials `f(x)` and `g(x)` with `\\deg f > 0`\n",
      " |      and `\\deg g > 0` the dispersion set `\\operatorname{J}(f, g)` is defined as:\n",
      " |      \n",
      " |      .. math::\n",
      " |          \\operatorname{J}(f, g)\n",
      " |          & := \\{a \\in \\mathbb{N}_0 | \\gcd(f(x), g(x+a)) \\neq 1\\} \\\\\n",
      " |          &  = \\{a \\in \\mathbb{N}_0 | \\deg \\gcd(f(x), g(x+a)) \\geq 1\\}\n",
      " |      \n",
      " |      For a single polynomial one defines `\\operatorname{J}(f) := \\operatorname{J}(f, f)`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import poly\n",
      " |      >>> from sympy.polys.dispersion import dispersion, dispersionset\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      Dispersion set and dispersion of a simple polynomial:\n",
      " |      \n",
      " |      >>> fp = poly((x - 3)*(x + 3), x)\n",
      " |      >>> sorted(dispersionset(fp))\n",
      " |      [0, 6]\n",
      " |      >>> dispersion(fp)\n",
      " |      6\n",
      " |      \n",
      " |      Note that the definition of the dispersion is not symmetric:\n",
      " |      \n",
      " |      >>> fp = poly(x**4 - 3*x**2 + 1, x)\n",
      " |      >>> gp = fp.shift(-3)\n",
      " |      >>> sorted(dispersionset(fp, gp))\n",
      " |      [2, 3, 4]\n",
      " |      >>> dispersion(fp, gp)\n",
      " |      4\n",
      " |      >>> sorted(dispersionset(gp, fp))\n",
      " |      []\n",
      " |      >>> dispersion(gp, fp)\n",
      " |      -oo\n",
      " |      \n",
      " |      Computing the dispersion also works over field extensions:\n",
      " |      \n",
      " |      >>> from sympy import sqrt\n",
      " |      >>> fp = poly(x**2 + sqrt(5)*x - 1, x, domain='QQ<sqrt(5)>')\n",
      " |      >>> gp = poly(x**2 + (2 + sqrt(5))*x + sqrt(5), x, domain='QQ<sqrt(5)>')\n",
      " |      >>> sorted(dispersionset(fp, gp))\n",
      " |      [2]\n",
      " |      >>> sorted(dispersionset(gp, fp))\n",
      " |      [1, 4]\n",
      " |      \n",
      " |      We can even perform the computations for polynomials\n",
      " |      having symbolic coefficients:\n",
      " |      \n",
      " |      >>> from sympy.abc import a\n",
      " |      >>> fp = poly(4*x**4 + (4*a + 8)*x**3 + (a**2 + 6*a + 4)*x**2 + (a**2 + 2*a)*x, x)\n",
      " |      >>> sorted(dispersionset(fp))\n",
      " |      [0, 1]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      dispersion\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      1. [ManWright94]_\n",
      " |      2. [Koepf98]_\n",
      " |      3. [Abramov71]_\n",
      " |      4. [Man93]_\n",
      " |  \n",
      " |  div(f, g, auto=True)\n",
      " |      Polynomial division with remainder of ``f`` by ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).div(Poly(2*x - 4, x))\n",
      " |      (Poly(1/2*x + 1, x, domain='QQ'), Poly(5, x, domain='QQ'))\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).div(Poly(2*x - 4, x), auto=False)\n",
      " |      (Poly(0, x, domain='ZZ'), Poly(x**2 + 1, x, domain='ZZ'))\n",
      " |  \n",
      " |  eject(f, *gens)\n",
      " |      Eject selected generators into the ground domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> f = Poly(x**2*y + x*y**3 + x*y + 1, x, y)\n",
      " |      \n",
      " |      >>> f.eject(x)\n",
      " |      Poly(x*y**3 + (x**2 + x)*y + 1, y, domain='ZZ[x]')\n",
      " |      >>> f.eject(y)\n",
      " |      Poly(y*x**2 + (y**3 + y)*x + 1, x, domain='ZZ[y]')\n",
      " |  \n",
      " |  eq(f, g, strict=False)\n",
      " |  \n",
      " |  eval(self, x, a=None, auto=True)\n",
      " |      Evaluate ``f`` at ``a`` in the given variable.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> Poly(x**2 + 2*x + 3, x).eval(2)\n",
      " |      11\n",
      " |      \n",
      " |      >>> Poly(2*x*y + 3*x + y + 2, x, y).eval(x, 2)\n",
      " |      Poly(5*y + 8, y, domain='ZZ')\n",
      " |      \n",
      " |      >>> f = Poly(2*x*y + 3*x + y + 2*z, x, y, z)\n",
      " |      \n",
      " |      >>> f.eval({x: 2})\n",
      " |      Poly(5*y + 2*z + 6, y, z, domain='ZZ')\n",
      " |      >>> f.eval({x: 2, y: 5})\n",
      " |      Poly(2*z + 31, z, domain='ZZ')\n",
      " |      >>> f.eval({x: 2, y: 5, z: 7})\n",
      " |      45\n",
      " |      \n",
      " |      >>> f.eval((2, 5))\n",
      " |      Poly(2*z + 31, z, domain='ZZ')\n",
      " |      >>> f(2, 5)\n",
      " |      Poly(2*z + 31, z, domain='ZZ')\n",
      " |  \n",
      " |  exclude(f)\n",
      " |      Remove unnecessary generators from ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import a, b, c, d, x\n",
      " |      \n",
      " |      >>> Poly(a + x, a, b, c, d, x).exclude()\n",
      " |      Poly(a + x, a, x, domain='ZZ')\n",
      " |  \n",
      " |  exquo(f, g, auto=True)\n",
      " |      Computes polynomial exact quotient of ``f`` by ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).exquo(Poly(x - 1, x))\n",
      " |      Poly(x + 1, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).exquo(Poly(2*x - 4, x))\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      ExactQuotientFailed: 2*x - 4 does not divide x**2 + 1\n",
      " |  \n",
      " |  exquo_ground(f, coeff)\n",
      " |      Exact quotient of ``f`` by a an element of the ground domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(2*x + 4).exquo_ground(2)\n",
      " |      Poly(x + 2, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(2*x + 3).exquo_ground(2)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      ExactQuotientFailed: 2 does not divide 3 in ZZ\n",
      " |  \n",
      " |  factor_list(f)\n",
      " |      Returns a list of irreducible factors of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> f = 2*x**5 + 2*x**4*y + 4*x**3 + 4*x**2*y + 2*x + 2*y\n",
      " |      \n",
      " |      >>> Poly(f).factor_list()\n",
      " |      (2, [(Poly(x + y, x, y, domain='ZZ'), 1),\n",
      " |           (Poly(x**2 + 1, x, y, domain='ZZ'), 2)])\n",
      " |  \n",
      " |  factor_list_include(f)\n",
      " |      Returns a list of irreducible factors of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> f = 2*x**5 + 2*x**4*y + 4*x**3 + 4*x**2*y + 2*x + 2*y\n",
      " |      \n",
      " |      >>> Poly(f).factor_list_include()\n",
      " |      [(Poly(2*x + 2*y, x, y, domain='ZZ'), 1),\n",
      " |       (Poly(x**2 + 1, x, y, domain='ZZ'), 2)]\n",
      " |  \n",
      " |  gcd(f, g)\n",
      " |      Returns the polynomial GCD of ``f`` and ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).gcd(Poly(x**2 - 3*x + 2, x))\n",
      " |      Poly(x - 1, x, domain='ZZ')\n",
      " |  \n",
      " |  gcdex(f, g, auto=True)\n",
      " |      Extended Euclidean algorithm of ``f`` and ``g``.\n",
      " |      \n",
      " |      Returns ``(s, t, h)`` such that ``h = gcd(f, g)`` and ``s*f + t*g = h``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = x**4 - 2*x**3 - 6*x**2 + 12*x + 15\n",
      " |      >>> g = x**3 + x**2 - 4*x - 4\n",
      " |      \n",
      " |      >>> Poly(f).gcdex(Poly(g))\n",
      " |      (Poly(-1/5*x + 3/5, x, domain='QQ'),\n",
      " |       Poly(1/5*x**2 - 6/5*x + 2, x, domain='QQ'),\n",
      " |       Poly(x + 1, x, domain='QQ'))\n",
      " |  \n",
      " |  get_domain(f)\n",
      " |      Get the ground domain of ``f``.\n",
      " |  \n",
      " |  get_modulus(f)\n",
      " |      Get the modulus of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, modulus=2).get_modulus()\n",
      " |      2\n",
      " |  \n",
      " |  gff_list(f)\n",
      " |      Computes greatest factorial factorization of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = x**5 + 2*x**4 - x**3 - 2*x**2\n",
      " |      \n",
      " |      >>> Poly(f).gff_list()\n",
      " |      [(Poly(x, x, domain='ZZ'), 1), (Poly(x + 2, x, domain='ZZ'), 4)]\n",
      " |  \n",
      " |  ground_roots(f)\n",
      " |      Compute roots of ``f`` by factorization in the ground domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**6 - 4*x**4 + 4*x**3 - x**2).ground_roots()\n",
      " |      {0: 2, 1: 2}\n",
      " |  \n",
      " |  half_gcdex(f, g, auto=True)\n",
      " |      Half extended Euclidean algorithm of ``f`` and ``g``.\n",
      " |      \n",
      " |      Returns ``(s, h)`` such that ``h = gcd(f, g)`` and ``s*f = h (mod g)``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = x**4 - 2*x**3 - 6*x**2 + 12*x + 15\n",
      " |      >>> g = x**3 + x**2 - 4*x - 4\n",
      " |      \n",
      " |      >>> Poly(f).half_gcdex(Poly(g))\n",
      " |      (Poly(-1/5*x + 3/5, x, domain='QQ'), Poly(x + 1, x, domain='QQ'))\n",
      " |  \n",
      " |  has_only_gens(f, *gens)\n",
      " |      Return ``True`` if ``Poly(f, *gens)`` retains ground domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> Poly(x*y + 1, x, y, z).has_only_gens(x, y)\n",
      " |      True\n",
      " |      >>> Poly(x*y + z, x, y, z).has_only_gens(x, y)\n",
      " |      False\n",
      " |  \n",
      " |  homogeneous_order(f)\n",
      " |      Returns the homogeneous order of ``f``.\n",
      " |      \n",
      " |      A homogeneous polynomial is a polynomial whose all monomials with\n",
      " |      non-zero coefficients have the same total degree. This degree is\n",
      " |      the homogeneous order of ``f``. If you only want to check if a\n",
      " |      polynomial is homogeneous, then use :func:`Poly.is_homogeneous`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> f = Poly(x**5 + 2*x**3*y**2 + 9*x*y**4)\n",
      " |      >>> f.homogeneous_order()\n",
      " |      5\n",
      " |  \n",
      " |  homogenize(f, s)\n",
      " |      Returns the homogeneous polynomial of ``f``.\n",
      " |      \n",
      " |      A homogeneous polynomial is a polynomial whose all monomials with\n",
      " |      non-zero coefficients have the same total degree. If you only\n",
      " |      want to check if a polynomial is homogeneous, then use\n",
      " |      :func:`Poly.is_homogeneous`. If you want not only to check if a\n",
      " |      polynomial is homogeneous but also compute its homogeneous order,\n",
      " |      then use :func:`Poly.homogeneous_order`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> f = Poly(x**5 + 2*x**2*y**2 + 9*x*y**3)\n",
      " |      >>> f.homogenize(z)\n",
      " |      Poly(x**5 + 2*x**2*y**2*z + 9*x*y**3*z, x, y, z, domain='ZZ')\n",
      " |  \n",
      " |  inject(f, front=False)\n",
      " |      Inject ground domain generators into ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> f = Poly(x**2*y + x*y**3 + x*y + 1, x)\n",
      " |      \n",
      " |      >>> f.inject()\n",
      " |      Poly(x**2*y + x*y**3 + x*y + 1, x, y, domain='ZZ')\n",
      " |      >>> f.inject(front=True)\n",
      " |      Poly(y**3*x + y*x**2 + y*x + 1, y, x, domain='ZZ')\n",
      " |  \n",
      " |  integrate(self, *specs, **args)\n",
      " |      Computes indefinite integral of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + 2*x + 1, x).integrate()\n",
      " |      Poly(1/3*x**3 + x**2 + x, x, domain='QQ')\n",
      " |      \n",
      " |      >>> Poly(x*y**2 + x, x, y).integrate((0, 1), (1, 0))\n",
      " |      Poly(1/2*x**2*y**2 + 1/2*x**2, x, y, domain='QQ')\n",
      " |  \n",
      " |  intervals(f, all=False, eps=None, inf=None, sup=None, fast=False, sqf=False)\n",
      " |      Compute isolating intervals for roots of ``f``.\n",
      " |      \n",
      " |      For real roots the Vincent-Akritas-Strzebonski (VAS) continued fractions method is used.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      .. [#] Alkiviadis G. Akritas and Adam W. Strzebonski: A Comparative Study of Two Real Root\n",
      " |          Isolation Methods . Nonlinear Analysis: Modelling and Control, Vol. 10, No. 4, 297-304, 2005.\n",
      " |      .. [#] Alkiviadis G. Akritas, Adam W. Strzebonski and Panagiotis S. Vigklas: Improving the\n",
      " |          Performance of the Continued Fractions Method Using new Bounds of Positive Roots. Nonlinear\n",
      " |          Analysis: Modelling and Control, Vol. 13, No. 3, 265-279, 2008.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 3, x).intervals()\n",
      " |      [((-2, -1), 1), ((1, 2), 1)]\n",
      " |      >>> Poly(x**2 - 3, x).intervals(eps=1e-2)\n",
      " |      [((-26/15, -19/11), 1), ((19/11, 26/15), 1)]\n",
      " |  \n",
      " |  invert(f, g, auto=True)\n",
      " |      Invert ``f`` modulo ``g`` when possible.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).invert(Poly(2*x - 1, x))\n",
      " |      Poly(-4/3, x, domain='QQ')\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).invert(Poly(x - 1, x))\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      NotInvertible: zero divisor\n",
      " |  \n",
      " |  l1_norm(f)\n",
      " |      Returns l1 norm of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(-x**2 + 2*x - 3, x).l1_norm()\n",
      " |      6\n",
      " |  \n",
      " |  lcm(f, g)\n",
      " |      Returns polynomial LCM of ``f`` and ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).lcm(Poly(x**2 - 3*x + 2, x))\n",
      " |      Poly(x**3 - 2*x**2 - x + 2, x, domain='ZZ')\n",
      " |  \n",
      " |  length(f)\n",
      " |      Returns the number of non-zero terms in ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 2*x - 1).length()\n",
      " |      3\n",
      " |  \n",
      " |  lift(f)\n",
      " |      Convert algebraic coefficients to rationals.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, I\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + I*x + 1, x, extension=I).lift()\n",
      " |      Poly(x**4 + 3*x**2 + 1, x, domain='QQ')\n",
      " |  \n",
      " |  ltrim(f, gen)\n",
      " |      Remove dummy generators from ``f`` that are to the left of\n",
      " |      specified ``gen`` in the generators as ordered. When ``gen``\n",
      " |      is an integer, it refers to the generator located at that\n",
      " |      position within the tuple of generators of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> Poly(y**2 + y*z**2, x, y, z).ltrim(y)\n",
      " |      Poly(y**2 + y*z**2, y, z, domain='ZZ')\n",
      " |      >>> Poly(z, x, y, z).ltrim(-1)\n",
      " |      Poly(z, z, domain='ZZ')\n",
      " |  \n",
      " |  match(f, *args, **kwargs)\n",
      " |      Match expression from Poly. See Basic.match()\n",
      " |  \n",
      " |  max_norm(f)\n",
      " |      Returns maximum norm of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(-x**2 + 2*x - 3, x).max_norm()\n",
      " |      3\n",
      " |  \n",
      " |  monic(self, auto=True)\n",
      " |      Divides all coefficients by ``LC(f)``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, ZZ\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(3*x**2 + 6*x + 9, x, domain=ZZ).monic()\n",
      " |      Poly(x**2 + 2*x + 3, x, domain='QQ')\n",
      " |      \n",
      " |      >>> Poly(3*x**2 + 4*x + 2, x, domain=ZZ).monic()\n",
      " |      Poly(x**2 + 4/3*x + 2/3, x, domain='QQ')\n",
      " |  \n",
      " |  monoms(f, order=None)\n",
      " |      Returns all non-zero monomials from ``f`` in lex order.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + 2*x*y**2 + x*y + 3*y, x, y).monoms()\n",
      " |      [(2, 0), (1, 2), (1, 1), (0, 1)]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      all_monoms\n",
      " |  \n",
      " |  mul(f, g)\n",
      " |      Multiply two polynomials ``f`` and ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).mul(Poly(x - 2, x))\n",
      " |      Poly(x**3 - 2*x**2 + x - 2, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x)*Poly(x - 2, x)\n",
      " |      Poly(x**3 - 2*x**2 + x - 2, x, domain='ZZ')\n",
      " |  \n",
      " |  mul_ground(f, coeff)\n",
      " |      Multiply ``f`` by a an element of the ground domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x + 1).mul_ground(2)\n",
      " |      Poly(2*x + 2, x, domain='ZZ')\n",
      " |  \n",
      " |  ne(f, g, strict=False)\n",
      " |  \n",
      " |  neg(f)\n",
      " |      Negate all coefficients in ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).neg()\n",
      " |      Poly(-x**2 + 1, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> -Poly(x**2 - 1, x)\n",
      " |      Poly(-x**2 + 1, x, domain='ZZ')\n",
      " |  \n",
      " |  norm(f)\n",
      " |      Computes the product, ``Norm(f)``, of the conjugates of\n",
      " |      a polynomial ``f`` defined over a number field ``K``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, sqrt\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> a, b = sqrt(2), sqrt(3)\n",
      " |      \n",
      " |      A polynomial over a quadratic extension.\n",
      " |      Two conjugates x - a and x + a.\n",
      " |      \n",
      " |      >>> f = Poly(x - a, x, extension=a)\n",
      " |      >>> f.norm()\n",
      " |      Poly(x**2 - 2, x, domain='QQ')\n",
      " |      \n",
      " |      A polynomial over a quartic extension.\n",
      " |      Four conjugates x - a, x - a, x + a and x + a.\n",
      " |      \n",
      " |      >>> f = Poly(x - a, x, extension=(a, b))\n",
      " |      >>> f.norm()\n",
      " |      Poly(x**4 - 4*x**2 + 4, x, domain='QQ')\n",
      " |  \n",
      " |  nroots(f, n=15, maxsteps=50, cleanup=True)\n",
      " |      Compute numerical approximations of roots of ``f``.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      n ... the number of digits to calculate\n",
      " |      maxsteps ... the maximum number of iterations to do\n",
      " |      \n",
      " |      If the accuracy `n` cannot be reached in `maxsteps`, it will raise an\n",
      " |      exception. You need to rerun with higher maxsteps.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 3).nroots(n=15)\n",
      " |      [-1.73205080756888, 1.73205080756888]\n",
      " |      >>> Poly(x**2 - 3).nroots(n=30)\n",
      " |      [-1.73205080756887729352744634151, 1.73205080756887729352744634151]\n",
      " |  \n",
      " |  nth(f, *N)\n",
      " |      Returns the ``n``-th coefficient of ``f`` where ``N`` are the\n",
      " |      exponents of the generators in the term of interest.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, sqrt\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**3 + 2*x**2 + 3*x, x).nth(2)\n",
      " |      2\n",
      " |      >>> Poly(x**3 + 2*x*y**2 + y**2, x, y).nth(1, 2)\n",
      " |      2\n",
      " |      >>> Poly(4*sqrt(x)*y)\n",
      " |      Poly(4*y*(sqrt(x)), y, sqrt(x), domain='ZZ')\n",
      " |      >>> _.nth(1, 1)\n",
      " |      4\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      coeff_monomial\n",
      " |  \n",
      " |  nth_power_roots_poly(f, n)\n",
      " |      Construct a polynomial with n-th powers of roots of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = Poly(x**4 - x**2 + 1)\n",
      " |      \n",
      " |      >>> f.nth_power_roots_poly(2)\n",
      " |      Poly(x**4 - 2*x**3 + 3*x**2 - 2*x + 1, x, domain='ZZ')\n",
      " |      >>> f.nth_power_roots_poly(3)\n",
      " |      Poly(x**4 + 2*x**2 + 1, x, domain='ZZ')\n",
      " |      >>> f.nth_power_roots_poly(4)\n",
      " |      Poly(x**4 + 2*x**3 + 3*x**2 + 2*x + 1, x, domain='ZZ')\n",
      " |      >>> f.nth_power_roots_poly(12)\n",
      " |      Poly(x**4 - 4*x**3 + 6*x**2 - 4*x + 1, x, domain='ZZ')\n",
      " |  \n",
      " |  pdiv(f, g)\n",
      " |      Polynomial pseudo-division of ``f`` by ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).pdiv(Poly(2*x - 4, x))\n",
      " |      (Poly(2*x + 4, x, domain='ZZ'), Poly(20, x, domain='ZZ'))\n",
      " |  \n",
      " |  per(f, rep, gens=None, remove=None)\n",
      " |      Create a Poly out of the given representation.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, ZZ\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> from sympy.polys.polyclasses import DMP\n",
      " |      \n",
      " |      >>> a = Poly(x**2 + 1)\n",
      " |      \n",
      " |      >>> a.per(DMP([ZZ(1), ZZ(1)], ZZ), gens=[y])\n",
      " |      Poly(y + 1, y, domain='ZZ')\n",
      " |  \n",
      " |  pexquo(f, g)\n",
      " |      Polynomial exact pseudo-quotient of ``f`` by ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).pexquo(Poly(2*x - 2, x))\n",
      " |      Poly(2*x + 2, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).pexquo(Poly(2*x - 4, x))\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      ExactQuotientFailed: 2*x - 4 does not divide x**2 + 1\n",
      " |  \n",
      " |  pow(f, n)\n",
      " |      Raise ``f`` to a non-negative power ``n``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x - 2, x).pow(3)\n",
      " |      Poly(x**3 - 6*x**2 + 12*x - 8, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x - 2, x)**3\n",
      " |      Poly(x**3 - 6*x**2 + 12*x - 8, x, domain='ZZ')\n",
      " |  \n",
      " |  pquo(f, g)\n",
      " |      Polynomial pseudo-quotient of ``f`` by ``g``.\n",
      " |      \n",
      " |      See the Caveat note in the function prem(f, g).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).pquo(Poly(2*x - 4, x))\n",
      " |      Poly(2*x + 4, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).pquo(Poly(2*x - 2, x))\n",
      " |      Poly(2*x + 2, x, domain='ZZ')\n",
      " |  \n",
      " |  prem(f, g)\n",
      " |      Polynomial pseudo-remainder of ``f`` by ``g``.\n",
      " |      \n",
      " |      Caveat: The function prem(f, g, x) can be safely used to compute\n",
      " |        in Z[x] _only_ subresultant polynomial remainder sequences (prs's).\n",
      " |      \n",
      " |        To safely compute Euclidean and Sturmian prs's in Z[x]\n",
      " |        employ anyone of the corresponding functions found in\n",
      " |        the module sympy.polys.subresultants_qq_zz. The functions\n",
      " |        in the module with suffix _pg compute prs's in Z[x] employing\n",
      " |        rem(f, g, x), whereas the functions with suffix _amv\n",
      " |        compute prs's in Z[x] employing rem_z(f, g, x).\n",
      " |      \n",
      " |        The function rem_z(f, g, x) differs from prem(f, g, x) in that\n",
      " |        to compute the remainder polynomials in Z[x] it premultiplies\n",
      " |        the divident times the absolute value of the leading coefficient\n",
      " |        of the divisor raised to the power degree(f, x) - degree(g, x) + 1.\n",
      " |      \n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).prem(Poly(2*x - 4, x))\n",
      " |      Poly(20, x, domain='ZZ')\n",
      " |  \n",
      " |  primitive(f)\n",
      " |      Returns the content and a primitive form of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(2*x**2 + 8*x + 12, x).primitive()\n",
      " |      (2, Poly(x**2 + 4*x + 6, x, domain='ZZ'))\n",
      " |  \n",
      " |  quo(f, g, auto=True)\n",
      " |      Computes polynomial quotient of ``f`` by ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).quo(Poly(2*x - 4, x))\n",
      " |      Poly(1/2*x + 1, x, domain='QQ')\n",
      " |      \n",
      " |      >>> Poly(x**2 - 1, x).quo(Poly(x - 1, x))\n",
      " |      Poly(x + 1, x, domain='ZZ')\n",
      " |  \n",
      " |  quo_ground(f, coeff)\n",
      " |      Quotient of ``f`` by a an element of the ground domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(2*x + 4).quo_ground(2)\n",
      " |      Poly(x + 2, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(2*x + 3).quo_ground(2)\n",
      " |      Poly(x + 1, x, domain='ZZ')\n",
      " |  \n",
      " |  rat_clear_denoms(self, g)\n",
      " |      Clear denominators in a rational function ``f/g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> f = Poly(x**2/y + 1, x)\n",
      " |      >>> g = Poly(x**3 + y, x)\n",
      " |      \n",
      " |      >>> p, q = f.rat_clear_denoms(g)\n",
      " |      \n",
      " |      >>> p\n",
      " |      Poly(x**2 + y, x, domain='ZZ[y]')\n",
      " |      >>> q\n",
      " |      Poly(y*x**3 + y**2, x, domain='ZZ[y]')\n",
      " |  \n",
      " |  real_roots(f, multiple=True, radicals=True)\n",
      " |      Return a list of real roots with multiplicities.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(2*x**3 - 7*x**2 + 4*x + 4).real_roots()\n",
      " |      [-1/2, 2, 2]\n",
      " |      >>> Poly(x**3 + x + 1).real_roots()\n",
      " |      [CRootOf(x**3 + x + 1, 0)]\n",
      " |  \n",
      " |  refine_root(f, s, t, eps=None, steps=None, fast=False, check_sqf=False)\n",
      " |      Refine an isolating interval of a root to the given precision.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 3, x).refine_root(1, 2, eps=1e-2)\n",
      " |      (19/11, 26/15)\n",
      " |  \n",
      " |  rem(f, g, auto=True)\n",
      " |      Computes the polynomial remainder of ``f`` by ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).rem(Poly(2*x - 4, x))\n",
      " |      Poly(5, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).rem(Poly(2*x - 4, x), auto=False)\n",
      " |      Poly(x**2 + 1, x, domain='ZZ')\n",
      " |  \n",
      " |  reorder(f, *gens, **args)\n",
      " |      Efficiently apply new order of generators.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + x*y**2, x, y).reorder(y, x)\n",
      " |      Poly(y**2*x + x**2, y, x, domain='ZZ')\n",
      " |  \n",
      " |  replace(f, x, y=None, **_ignore)\n",
      " |      Replace ``x`` with ``y`` in generators list.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).replace(x, y)\n",
      " |      Poly(y**2 + 1, y, domain='ZZ')\n",
      " |  \n",
      " |  resultant(f, g, includePRS=False)\n",
      " |      Computes the resultant of ``f`` and ``g`` via PRS.\n",
      " |      \n",
      " |      If includePRS=True, it includes the subresultant PRS in the result.\n",
      " |      Because the PRS is used to calculate the resultant, this is more\n",
      " |      efficient than calling :func:`subresultants` separately.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = Poly(x**2 + 1, x)\n",
      " |      \n",
      " |      >>> f.resultant(Poly(x**2 - 1, x))\n",
      " |      4\n",
      " |      >>> f.resultant(Poly(x**2 - 1, x), includePRS=True)\n",
      " |      (4, [Poly(x**2 + 1, x, domain='ZZ'), Poly(x**2 - 1, x, domain='ZZ'),\n",
      " |           Poly(-2, x, domain='ZZ')])\n",
      " |  \n",
      " |  retract(f, field=None)\n",
      " |      Recalculate the ground domain of a polynomial.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = Poly(x**2 + 1, x, domain='QQ[y]')\n",
      " |      >>> f\n",
      " |      Poly(x**2 + 1, x, domain='QQ[y]')\n",
      " |      \n",
      " |      >>> f.retract()\n",
      " |      Poly(x**2 + 1, x, domain='ZZ')\n",
      " |      >>> f.retract(field=True)\n",
      " |      Poly(x**2 + 1, x, domain='QQ')\n",
      " |  \n",
      " |  revert(f, n)\n",
      " |      Compute ``f**(-1)`` mod ``x**n``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(1, x).revert(2)\n",
      " |      Poly(1, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(1 + x, x).revert(1)\n",
      " |      Poly(1, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x**2 - 2, x).revert(2)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      NotReversible: only units are reversible in a ring\n",
      " |      \n",
      " |      >>> Poly(1/x, x).revert(1)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      PolynomialError: 1/x contains an element of the generators set\n",
      " |  \n",
      " |  root(f, index, radicals=True)\n",
      " |      Get an indexed root of a polynomial.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = Poly(2*x**3 - 7*x**2 + 4*x + 4)\n",
      " |      \n",
      " |      >>> f.root(0)\n",
      " |      -1/2\n",
      " |      >>> f.root(1)\n",
      " |      2\n",
      " |      >>> f.root(2)\n",
      " |      2\n",
      " |      >>> f.root(3)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      IndexError: root index out of [-3, 2] range, got 3\n",
      " |      \n",
      " |      >>> Poly(x**5 + x + 1).root(0)\n",
      " |      CRootOf(x**3 - x**2 + 1, 0)\n",
      " |  \n",
      " |  same_root(f, a, b)\n",
      " |      Decide whether two roots of this polynomial are equal.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, cyclotomic_poly, exp, I, pi\n",
      " |      >>> f = Poly(cyclotomic_poly(5))\n",
      " |      >>> r0 = exp(2*I*pi/5)\n",
      " |      >>> indices = [i for i, r in enumerate(f.all_roots()) if f.same_root(r, r0)]\n",
      " |      >>> print(indices)\n",
      " |      [3]\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      DomainError\n",
      " |          If the domain of the polynomial is not :ref:`ZZ`, :ref:`QQ`,\n",
      " |          :ref:`RR`, or :ref:`CC`.\n",
      " |      MultivariatePolynomialError\n",
      " |          If the polynomial is not univariate.\n",
      " |      PolynomialError\n",
      " |          If the polynomial is of degree < 2.\n",
      " |  \n",
      " |  set_domain(f, domain)\n",
      " |      Set the ground domain of ``f``.\n",
      " |  \n",
      " |  set_modulus(f, modulus)\n",
      " |      Set the modulus of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(5*x**2 + 2*x - 1, x).set_modulus(2)\n",
      " |      Poly(x**2 + 1, x, modulus=2)\n",
      " |  \n",
      " |  shift(f, a)\n",
      " |      Efficiently compute Taylor shift ``f(x + a)``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 2*x + 1, x).shift(2)\n",
      " |      Poly(x**2 + 2*x + 1, x, domain='ZZ')\n",
      " |  \n",
      " |  slice(f, x, m, n=None)\n",
      " |      Take a continuous subsequence of terms of ``f``.\n",
      " |  \n",
      " |  sqf_list(f, all=False)\n",
      " |      Returns a list of square-free factors of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = 2*x**5 + 16*x**4 + 50*x**3 + 76*x**2 + 56*x + 16\n",
      " |      \n",
      " |      >>> Poly(f).sqf_list()\n",
      " |      (2, [(Poly(x + 1, x, domain='ZZ'), 2),\n",
      " |           (Poly(x + 2, x, domain='ZZ'), 3)])\n",
      " |      \n",
      " |      >>> Poly(f).sqf_list(all=True)\n",
      " |      (2, [(Poly(1, x, domain='ZZ'), 1),\n",
      " |           (Poly(x + 1, x, domain='ZZ'), 2),\n",
      " |           (Poly(x + 2, x, domain='ZZ'), 3)])\n",
      " |  \n",
      " |  sqf_list_include(f, all=False)\n",
      " |      Returns a list of square-free factors of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, expand\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = expand(2*(x + 1)**3*x**4)\n",
      " |      >>> f\n",
      " |      2*x**7 + 6*x**6 + 6*x**5 + 2*x**4\n",
      " |      \n",
      " |      >>> Poly(f).sqf_list_include()\n",
      " |      [(Poly(2, x, domain='ZZ'), 1),\n",
      " |       (Poly(x + 1, x, domain='ZZ'), 3),\n",
      " |       (Poly(x, x, domain='ZZ'), 4)]\n",
      " |      \n",
      " |      >>> Poly(f).sqf_list_include(all=True)\n",
      " |      [(Poly(2, x, domain='ZZ'), 1),\n",
      " |       (Poly(1, x, domain='ZZ'), 2),\n",
      " |       (Poly(x + 1, x, domain='ZZ'), 3),\n",
      " |       (Poly(x, x, domain='ZZ'), 4)]\n",
      " |  \n",
      " |  sqf_norm(f)\n",
      " |      Computes square-free norm of ``f``.\n",
      " |      \n",
      " |      Returns ``s``, ``f``, ``r``, such that ``g(x) = f(x-sa)`` and\n",
      " |      ``r(x) = Norm(g(x))`` is a square-free polynomial over ``K``,\n",
      " |      where ``a`` is the algebraic extension of the ground domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, sqrt\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> s, f, r = Poly(x**2 + 1, x, extension=[sqrt(3)]).sqf_norm()\n",
      " |      \n",
      " |      >>> s\n",
      " |      1\n",
      " |      >>> f\n",
      " |      Poly(x**2 - 2*sqrt(3)*x + 4, x, domain='QQ<sqrt(3)>')\n",
      " |      >>> r\n",
      " |      Poly(x**4 - 4*x**2 + 16, x, domain='QQ')\n",
      " |  \n",
      " |  sqf_part(f)\n",
      " |      Computes square-free part of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**3 - 3*x - 2, x).sqf_part()\n",
      " |      Poly(x**2 - x - 2, x, domain='ZZ')\n",
      " |  \n",
      " |  sqr(f)\n",
      " |      Square a polynomial ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x - 2, x).sqr()\n",
      " |      Poly(x**2 - 4*x + 4, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x - 2, x)**2\n",
      " |      Poly(x**2 - 4*x + 4, x, domain='ZZ')\n",
      " |  \n",
      " |  sturm(self, auto=True)\n",
      " |      Computes the Sturm sequence of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**3 - 2*x**2 + x - 3, x).sturm()\n",
      " |      [Poly(x**3 - 2*x**2 + x - 3, x, domain='QQ'),\n",
      " |       Poly(3*x**2 - 4*x + 1, x, domain='QQ'),\n",
      " |       Poly(2/9*x + 25/9, x, domain='QQ'),\n",
      " |       Poly(-2079/4, x, domain='QQ')]\n",
      " |  \n",
      " |  sub(f, g)\n",
      " |      Subtract two polynomials ``f`` and ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).sub(Poly(x - 2, x))\n",
      " |      Poly(x**2 - x + 3, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x) - Poly(x - 2, x)\n",
      " |      Poly(x**2 - x + 3, x, domain='ZZ')\n",
      " |  \n",
      " |  sub_ground(f, coeff)\n",
      " |      Subtract an element of the ground domain from ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x + 1).sub_ground(2)\n",
      " |      Poly(x - 1, x, domain='ZZ')\n",
      " |  \n",
      " |  subresultants(f, g)\n",
      " |      Computes the subresultant PRS of ``f`` and ``g``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).subresultants(Poly(x**2 - 1, x))\n",
      " |      [Poly(x**2 + 1, x, domain='ZZ'),\n",
      " |       Poly(x**2 - 1, x, domain='ZZ'),\n",
      " |       Poly(-2, x, domain='ZZ')]\n",
      " |  \n",
      " |  terms(f, order=None)\n",
      " |      Returns all non-zero terms from ``f`` in lex order.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + 2*x*y**2 + x*y + 3*y, x, y).terms()\n",
      " |      [((2, 0), 1), ((1, 2), 2), ((1, 1), 1), ((0, 1), 3)]\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      all_terms\n",
      " |  \n",
      " |  terms_gcd(f)\n",
      " |      Remove GCD of terms from the polynomial ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**6*y**2 + x**3*y, x, y).terms_gcd()\n",
      " |      ((3, 1), Poly(x**3*y + 1, x, y, domain='ZZ'))\n",
      " |  \n",
      " |  termwise(f, func, *gens, **args)\n",
      " |      Apply a function to all terms of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> def func(k, coeff):\n",
      " |      ...     k = k[0]\n",
      " |      ...     return coeff//10**(2-k)\n",
      " |      \n",
      " |      >>> Poly(x**2 + 20*x + 400).termwise(func)\n",
      " |      Poly(x**2 + 2*x + 4, x, domain='ZZ')\n",
      " |  \n",
      " |  to_exact(f)\n",
      " |      Make the ground domain exact.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, RR\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1.0, x, domain=RR).to_exact()\n",
      " |      Poly(x**2 + 1, x, domain='QQ')\n",
      " |  \n",
      " |  to_field(f)\n",
      " |      Make the ground domain a field.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, ZZ\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x, domain=ZZ).to_field()\n",
      " |      Poly(x**2 + 1, x, domain='QQ')\n",
      " |  \n",
      " |  to_ring(f)\n",
      " |      Make the ground domain a ring.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, QQ\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, domain=QQ).to_ring()\n",
      " |      Poly(x**2 + 1, x, domain='ZZ')\n",
      " |  \n",
      " |  total_degree(f)\n",
      " |      Returns the total degree of ``f``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + y*x + 1, x, y).total_degree()\n",
      " |      2\n",
      " |      >>> Poly(x + y**5, x, y).total_degree()\n",
      " |      5\n",
      " |  \n",
      " |  transform(f, p, q)\n",
      " |      Efficiently evaluate the functional transformation ``q**n * f(p/q)``.\n",
      " |      \n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 2*x + 1, x).transform(Poly(x + 1, x), Poly(x - 1, x))\n",
      " |      Poly(4, x, domain='ZZ')\n",
      " |  \n",
      " |  trunc(f, p)\n",
      " |      Reduce ``f`` modulo a constant ``p``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(2*x**3 + 3*x**2 + 5*x + 7, x).trunc(3)\n",
      " |      Poly(-x**3 - x + 1, x, domain='ZZ')\n",
      " |  \n",
      " |  unify(f, g)\n",
      " |      Make ``f`` and ``g`` belong to the same domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f, g = Poly(x/2 + 1), Poly(2*x + 1)\n",
      " |      \n",
      " |      >>> f\n",
      " |      Poly(1/2*x + 1, x, domain='QQ')\n",
      " |      >>> g\n",
      " |      Poly(2*x + 1, x, domain='ZZ')\n",
      " |      \n",
      " |      >>> F, G = f.unify(g)\n",
      " |      \n",
      " |      >>> F\n",
      " |      Poly(1/2*x + 1, x, domain='QQ')\n",
      " |      >>> G\n",
      " |      Poly(2*x + 1, x, domain='QQ')\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods defined here:\n",
      " |  \n",
      " |  from_dict(rep, *gens, **args) from sympy.core.assumptions.ManagedProperties\n",
      " |      Construct a polynomial from a ``dict``.\n",
      " |  \n",
      " |  from_expr(rep, *gens, **args) from sympy.core.assumptions.ManagedProperties\n",
      " |      Construct a polynomial from an expression.\n",
      " |  \n",
      " |  from_list(rep, *gens, **args) from sympy.core.assumptions.ManagedProperties\n",
      " |      Construct a polynomial from a ``list``.\n",
      " |  \n",
      " |  from_poly(rep, *gens, **args) from sympy.core.assumptions.ManagedProperties\n",
      " |      Construct a polynomial from a polynomial.\n",
      " |  \n",
      " |  new(rep, *gens) from sympy.core.assumptions.ManagedProperties\n",
      " |      Construct :class:`Poly` instance from raw representation.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  __new__(cls, rep, *gens, **args)\n",
      " |      Create a new polynomial instance out of something useful.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties defined here:\n",
      " |  \n",
      " |  __sympy__\n",
      " |  \n",
      " |  args\n",
      " |      Returns a tuple of arguments of 'self'.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cot\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> cot(x).args\n",
      " |      (x,)\n",
      " |      \n",
      " |      >>> cot(x).args[0]\n",
      " |      x\n",
      " |      \n",
      " |      >>> (x*y).args\n",
      " |      (x, y)\n",
      " |      \n",
      " |      >>> (x*y).args[1]\n",
      " |      y\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Never use self._args, always use self.args.\n",
      " |      Only use _args in __new__ when creating a new function.\n",
      " |      Don't override .args() from Basic (so that it's easy to\n",
      " |      change the interface in the future if needed).\n",
      " |  \n",
      " |  domain\n",
      " |      Get the ground domain of a :py:class:`~.Poly`\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      :py:class:`~.Domain`:\n",
      " |          Ground domain of the :py:class:`~.Poly`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly, Symbol\n",
      " |      >>> x = Symbol('x')\n",
      " |      >>> p = Poly(x**2 + x)\n",
      " |      >>> p\n",
      " |      Poly(x**2 + x, x, domain='ZZ')\n",
      " |      >>> p.domain\n",
      " |      ZZ\n",
      " |  \n",
      " |  expr\n",
      " |  \n",
      " |  free_symbols\n",
      " |      Free symbols of a polynomial expression.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1).free_symbols\n",
      " |      {x}\n",
      " |      >>> Poly(x**2 + y).free_symbols\n",
      " |      {x, y}\n",
      " |      >>> Poly(x**2 + y, x).free_symbols\n",
      " |      {x, y}\n",
      " |      >>> Poly(x**2 + y, x, z).free_symbols\n",
      " |      {x, y}\n",
      " |  \n",
      " |  free_symbols_in_domain\n",
      " |      Free symbols of the domain of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1).free_symbols_in_domain\n",
      " |      set()\n",
      " |      >>> Poly(x**2 + y).free_symbols_in_domain\n",
      " |      set()\n",
      " |      >>> Poly(x**2 + y, x).free_symbols_in_domain\n",
      " |      {y}\n",
      " |  \n",
      " |  gen\n",
      " |      Return the principal generator.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + 1, x).gen\n",
      " |      x\n",
      " |  \n",
      " |  is_cyclotomic\n",
      " |      Returns ``True`` if ``f`` is a cyclotomic polnomial.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = x**16 + x**14 - x**10 + x**8 - x**6 + x**2 + 1\n",
      " |      \n",
      " |      >>> Poly(f).is_cyclotomic\n",
      " |      False\n",
      " |      \n",
      " |      >>> g = x**16 + x**14 - x**10 - x**8 - x**6 + x**2 + 1\n",
      " |      \n",
      " |      >>> Poly(g).is_cyclotomic\n",
      " |      True\n",
      " |  \n",
      " |  is_ground\n",
      " |      Returns ``True`` if ``f`` is an element of the ground domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x, x).is_ground\n",
      " |      False\n",
      " |      >>> Poly(2, x).is_ground\n",
      " |      True\n",
      " |      >>> Poly(y, x).is_ground\n",
      " |      True\n",
      " |  \n",
      " |  is_homogeneous\n",
      " |      Returns ``True`` if ``f`` is a homogeneous polynomial.\n",
      " |      \n",
      " |      A homogeneous polynomial is a polynomial whose all monomials with\n",
      " |      non-zero coefficients have the same total degree. If you want not\n",
      " |      only to check if a polynomial is homogeneous but also compute its\n",
      " |      homogeneous order, then use :func:`Poly.homogeneous_order`.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + x*y, x, y).is_homogeneous\n",
      " |      True\n",
      " |      >>> Poly(x**3 + x*y, x, y).is_homogeneous\n",
      " |      False\n",
      " |  \n",
      " |  is_irreducible\n",
      " |      Returns ``True`` if ``f`` has no factors over its domain.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 + x + 1, x, modulus=2).is_irreducible\n",
      " |      True\n",
      " |      >>> Poly(x**2 + 1, x, modulus=2).is_irreducible\n",
      " |      False\n",
      " |  \n",
      " |  is_linear\n",
      " |      Returns ``True`` if ``f`` is linear in all its variables.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x + y + 2, x, y).is_linear\n",
      " |      True\n",
      " |      >>> Poly(x*y + 2, x, y).is_linear\n",
      " |      False\n",
      " |  \n",
      " |  is_monic\n",
      " |      Returns ``True`` if the leading coefficient of ``f`` is one.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x + 2, x).is_monic\n",
      " |      True\n",
      " |      >>> Poly(2*x + 2, x).is_monic\n",
      " |      False\n",
      " |  \n",
      " |  is_monomial\n",
      " |      Returns ``True`` if ``f`` is zero or has only one term.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(3*x**2, x).is_monomial\n",
      " |      True\n",
      " |      >>> Poly(3*x**2 + 1, x).is_monomial\n",
      " |      False\n",
      " |  \n",
      " |  is_multivariate\n",
      " |      Returns ``True`` if ``f`` is a multivariate polynomial.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + x + 1, x).is_multivariate\n",
      " |      False\n",
      " |      >>> Poly(x*y**2 + x*y + 1, x, y).is_multivariate\n",
      " |      True\n",
      " |      >>> Poly(x*y**2 + x*y + 1, x).is_multivariate\n",
      " |      False\n",
      " |      >>> Poly(x**2 + x + 1, x, y).is_multivariate\n",
      " |      True\n",
      " |  \n",
      " |  is_one\n",
      " |      Returns ``True`` if ``f`` is a unit polynomial.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(0, x).is_one\n",
      " |      False\n",
      " |      >>> Poly(1, x).is_one\n",
      " |      True\n",
      " |  \n",
      " |  is_primitive\n",
      " |      Returns ``True`` if GCD of the coefficients of ``f`` is one.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(2*x**2 + 6*x + 12, x).is_primitive\n",
      " |      False\n",
      " |      >>> Poly(x**2 + 3*x + 6, x).is_primitive\n",
      " |      True\n",
      " |  \n",
      " |  is_quadratic\n",
      " |      Returns ``True`` if ``f`` is quadratic in all its variables.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x*y + 2, x, y).is_quadratic\n",
      " |      True\n",
      " |      >>> Poly(x*y**2 + 2, x, y).is_quadratic\n",
      " |      False\n",
      " |  \n",
      " |  is_sqf\n",
      " |      Returns ``True`` if ``f`` is a square-free polynomial.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(x**2 - 2*x + 1, x).is_sqf\n",
      " |      False\n",
      " |      >>> Poly(x**2 - 1, x).is_sqf\n",
      " |      True\n",
      " |  \n",
      " |  is_univariate\n",
      " |      Returns ``True`` if ``f`` is a univariate polynomial.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> Poly(x**2 + x + 1, x).is_univariate\n",
      " |      True\n",
      " |      >>> Poly(x*y**2 + x*y + 1, x, y).is_univariate\n",
      " |      False\n",
      " |      >>> Poly(x*y**2 + x*y + 1, x).is_univariate\n",
      " |      True\n",
      " |      >>> Poly(x**2 + x + 1, x, y).is_univariate\n",
      " |      False\n",
      " |  \n",
      " |  is_zero\n",
      " |      Returns ``True`` if ``f`` is a zero polynomial.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Poly(0, x).is_zero\n",
      " |      True\n",
      " |      >>> Poly(1, x).is_zero\n",
      " |      False\n",
      " |  \n",
      " |  one\n",
      " |      Return one polynomial with ``self``'s properties.\n",
      " |  \n",
      " |  unit\n",
      " |      Return unit polynomial with ``self``'s properties.\n",
      " |  \n",
      " |  zero\n",
      " |      Return zero polynomial with ``self``'s properties.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors defined here:\n",
      " |  \n",
      " |  gens\n",
      " |  \n",
      " |  rep\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes defined here:\n",
      " |  \n",
      " |  default_assumptions = {'commutative': True}\n",
      " |  \n",
      " |  is_Poly = True\n",
      " |  \n",
      " |  is_commutative = True\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __getnewargs__(self)\n",
      " |  \n",
      " |  __getstate__(self)\n",
      " |  \n",
      " |  __reduce_ex__(self, protocol)\n",
      " |      Helper for pickle.\n",
      " |  \n",
      " |  __setstate__(self, state)\n",
      " |  \n",
      " |  as_content_primitive(self, radical=False, clear=True)\n",
      " |      A stub to allow Basic args (like Tuple) to be skipped when computing\n",
      " |      the content and primitive components of an expression.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.core.expr.Expr.as_content_primitive\n",
      " |  \n",
      " |  as_dummy(self)\n",
      " |      Return the expression with any objects having structurally\n",
      " |      bound symbols replaced with unique, canonical symbols within\n",
      " |      the object in which they appear and having only the default\n",
      " |      assumption for commutativity being True. When applied to a\n",
      " |      symbol a new symbol having only the same commutativity will be\n",
      " |      returned.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> r = Symbol('r', real=True)\n",
      " |      >>> Integral(r, (r, x)).as_dummy()\n",
      " |      Integral(_0, (_0, x))\n",
      " |      >>> _.variables[0].is_real is None\n",
      " |      True\n",
      " |      >>> r.as_dummy()\n",
      " |      _r\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Any object that has structurally bound variables should have\n",
      " |      a property, `bound_symbols` that returns those symbols\n",
      " |      appearing in the object.\n",
      " |  \n",
      " |  atoms(self, *types)\n",
      " |      Returns the atoms that form the current object.\n",
      " |      \n",
      " |      By default, only objects that are truly atomic and cannot\n",
      " |      be divided into smaller pieces are returned: symbols, numbers,\n",
      " |      and number symbols like I and pi. It is possible to request\n",
      " |      atoms of any type, however, as demonstrated below.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import I, pi, sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms()\n",
      " |      {1, 2, I, pi, x, y}\n",
      " |      \n",
      " |      If one or more types are given, the results will contain only\n",
      " |      those types of atoms.\n",
      " |      \n",
      " |      >>> from sympy import Number, NumberSymbol, Symbol\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Symbol)\n",
      " |      {x, y}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number)\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol)\n",
      " |      {1, 2, pi}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol, I)\n",
      " |      {1, 2, I, pi}\n",
      " |      \n",
      " |      Note that I (imaginary unit) and zoo (complex infinity) are special\n",
      " |      types of number symbols and are not part of the NumberSymbol class.\n",
      " |      \n",
      " |      The type can be given implicitly, too:\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(x) # x is a Symbol\n",
      " |      {x, y}\n",
      " |      \n",
      " |      Be careful to check your assumptions when using the implicit option\n",
      " |      since ``S(1).is_Integer = True`` but ``type(S(1))`` is ``One``, a special type\n",
      " |      of SymPy atom, while ``type(S(2))`` is type ``Integer`` and will find all\n",
      " |      integers in an expression:\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(1))\n",
      " |      {1}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(2))\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      Finally, arguments to atoms() can select more than atomic atoms: any\n",
      " |      SymPy type (loaded in core/__init__.py) can be listed as an argument\n",
      " |      and those types of \"atoms\" as found in scanning the arguments of the\n",
      " |      expression recursively:\n",
      " |      \n",
      " |      >>> from sympy import Function, Mul\n",
      " |      >>> from sympy.core.function import AppliedUndef\n",
      " |      >>> f = Function('f')\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(Function)\n",
      " |      {f(x), sin(y + I*pi)}\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(AppliedUndef)\n",
      " |      {f(x)}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Mul)\n",
      " |      {I*pi, 2*sin(y + I*pi)}\n",
      " |  \n",
      " |  compare(self, other)\n",
      " |      Return -1, 0, 1 if the object is smaller, equal, or greater than other.\n",
      " |      \n",
      " |      Not in the mathematical sense. If the object is of a different type\n",
      " |      from the \"other\" then their classes are ordered according to\n",
      " |      the sorted_classes list.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> x.compare(y)\n",
      " |      -1\n",
      " |      >>> x.compare(x)\n",
      " |      0\n",
      " |      >>> y.compare(x)\n",
      " |      1\n",
      " |  \n",
      " |  copy(self)\n",
      " |  \n",
      " |  could_extract_minus_sign(self)\n",
      " |  \n",
      " |  count(self, query)\n",
      " |      Count the number of matching subexpressions.\n",
      " |  \n",
      " |  count_ops(self, visual=None)\n",
      " |      wrapper for count_ops that returns the operation count.\n",
      " |  \n",
      " |  doit(self, **hints)\n",
      " |      Evaluate objects that are not evaluated by default like limits,\n",
      " |      integrals, sums and products. All objects of this kind will be\n",
      " |      evaluated recursively, unless some species were excluded via 'hints'\n",
      " |      or unless the 'deep' hint was set to 'False'.\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> 2*Integral(x, x)\n",
      " |      2*Integral(x, x)\n",
      " |      \n",
      " |      >>> (2*Integral(x, x)).doit()\n",
      " |      x**2\n",
      " |      \n",
      " |      >>> (2*Integral(x, x)).doit(deep=False)\n",
      " |      2*Integral(x, x)\n",
      " |  \n",
      " |  dummy_eq(self, other, symbol=None)\n",
      " |      Compare two expressions and handle dummy symbols.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Dummy\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> u = Dummy('u')\n",
      " |      \n",
      " |      >>> (u**2 + 1).dummy_eq(x**2 + 1)\n",
      " |      True\n",
      " |      >>> (u**2 + 1) == (x**2 + 1)\n",
      " |      False\n",
      " |      \n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, x)\n",
      " |      True\n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, y)\n",
      " |      False\n",
      " |  \n",
      " |  find(self, query, group=False)\n",
      " |      Find all subexpressions matching a query.\n",
      " |  \n",
      " |  has(self, *patterns)\n",
      " |      Test whether any subexpression matches any of the patterns.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x**2 + sin(x*y)).has(z)\n",
      " |      False\n",
      " |      >>> (x**2 + sin(x*y)).has(x, y, z)\n",
      " |      True\n",
      " |      >>> x.has(x)\n",
      " |      True\n",
      " |      \n",
      " |      Note ``has`` is a structural algorithm with no knowledge of\n",
      " |      mathematics. Consider the following half-open interval:\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> i = Interval.Lopen(0, 5); i\n",
      " |      Interval.Lopen(0, 5)\n",
      " |      >>> i.args\n",
      " |      (0, 5, True, False)\n",
      " |      >>> i.has(4)  # there is no \"4\" in the arguments\n",
      " |      False\n",
      " |      >>> i.has(0)  # there *is* a \"0\" in the arguments\n",
      " |      True\n",
      " |      \n",
      " |      Instead, use ``contains`` to determine whether a number is in the\n",
      " |      interval or not:\n",
      " |      \n",
      " |      >>> i.contains(4)\n",
      " |      True\n",
      " |      >>> i.contains(0)\n",
      " |      False\n",
      " |      \n",
      " |      \n",
      " |      Note that ``expr.has(*patterns)`` is exactly equivalent to\n",
      " |      ``any(expr.has(p) for p in patterns)``. In particular, ``False`` is\n",
      " |      returned when the list of patterns is empty.\n",
      " |      \n",
      " |      >>> x.has()\n",
      " |      False\n",
      " |  \n",
      " |  has_free(self, *patterns)\n",
      " |      return True if self has object(s) ``x`` as a free expression\n",
      " |      else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Function\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = Function('f')\n",
      " |      >>> g = Function('g')\n",
      " |      >>> expr = Integral(f(x), (f(x), 1, g(y)))\n",
      " |      >>> expr.free_symbols\n",
      " |      {y}\n",
      " |      >>> expr.has_free(g(y))\n",
      " |      True\n",
      " |      >>> expr.has_free(*(x, f(x)))\n",
      " |      False\n",
      " |      \n",
      " |      This works for subexpressions and types, too:\n",
      " |      \n",
      " |      >>> expr.has_free(g)\n",
      " |      True\n",
      " |      >>> (x + y + 1).has_free(y + 1)\n",
      " |      True\n",
      " |  \n",
      " |  is_hypergeometric(self, k)\n",
      " |  \n",
      " |  matches(self, expr, repl_dict=None, old=False)\n",
      " |      Helper method for match() that looks for a match between Wild symbols\n",
      " |      in self and expressions in expr.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, Wild, Basic\n",
      " |      >>> a, b, c = symbols('a b c')\n",
      " |      >>> x = Wild('x')\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b, c)) is None\n",
      " |      True\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b + c, b + c))\n",
      " |      {x_: b + c}\n",
      " |  \n",
      " |  rcall(self, *args)\n",
      " |      Apply on the argument recursively through the expression tree.\n",
      " |      \n",
      " |      This method is used to simulate a common abuse of notation for\n",
      " |      operators. For instance, in SymPy the following will not work:\n",
      " |      \n",
      " |      ``(x+Lambda(y, 2*y))(z) == x+2*z``,\n",
      " |      \n",
      " |      however, you can use:\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x + Lambda(y, 2*y)).rcall(z)\n",
      " |      x + 2*z\n",
      " |  \n",
      " |  refine(self, assumption=True)\n",
      " |      See the refine function in sympy.assumptions\n",
      " |  \n",
      " |  rewrite(self, *args, deep=True, **hints)\n",
      " |      Rewrite *self* using a defined rule.\n",
      " |      \n",
      " |      Rewriting transforms an expression to another, which is mathematically\n",
      " |      equivalent but structurally different. For example you can rewrite\n",
      " |      trigonometric functions as complex exponentials or combinatorial\n",
      " |      functions as gamma function.\n",
      " |      \n",
      " |      This method takes a *pattern* and a *rule* as positional arguments.\n",
      " |      *pattern* is optional parameter which defines the types of expressions\n",
      " |      that will be transformed. If it is not passed, all possible expressions\n",
      " |      will be rewritten. *rule* defines how the expression will be rewritten.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      args : *rule*, or *pattern* and *rule*.\n",
      " |          - *pattern* is a type or an iterable of types.\n",
      " |          - *rule* can be any object.\n",
      " |      \n",
      " |      deep : bool, optional.\n",
      " |          If ``True``, subexpressions are recursively transformed. Default is\n",
      " |          ``True``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      If *pattern* is unspecified, all possible expressions are transformed.\n",
      " |      \n",
      " |      >>> from sympy import cos, sin, exp, I\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> expr = cos(x) + I*sin(x)\n",
      " |      >>> expr.rewrite(exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Pattern can be a type or an iterable of types.\n",
      " |      \n",
      " |      >>> expr.rewrite(sin, exp)\n",
      " |      exp(I*x)/2 + cos(x) - exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos,], exp)\n",
      " |      exp(I*x)/2 + I*sin(x) + exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos, sin], exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Rewriting behavior can be implemented by defining ``_eval_rewrite()``\n",
      " |      method.\n",
      " |      \n",
      " |      >>> from sympy import Expr, sqrt, pi\n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite(self, rule, args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         if rule == cos:\n",
      " |      ...             return cos(pi/2 - x, evaluate=False)\n",
      " |      ...         if rule == sqrt:\n",
      " |      ...             return sqrt(1 - cos(x)**2)\n",
      " |      >>> MySin(MySin(x)).rewrite(cos)\n",
      " |      cos(-cos(-x + pi/2) + pi/2)\n",
      " |      >>> MySin(x).rewrite(sqrt)\n",
      " |      sqrt(1 - cos(x)**2)\n",
      " |      \n",
      " |      Defining ``_eval_rewrite_as_[...]()`` method is supported for backwards\n",
      " |      compatibility reason. This may be removed in the future and using it is\n",
      " |      discouraged.\n",
      " |      \n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite_as_cos(self, *args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         return cos(pi/2 - x, evaluate=False)\n",
      " |      >>> MySin(x).rewrite(cos)\n",
      " |      cos(-x + pi/2)\n",
      " |  \n",
      " |  simplify(self, **kwargs)\n",
      " |      See the simplify function in sympy.simplify\n",
      " |  \n",
      " |  sort_key(self, order=None)\n",
      " |      Return a sort key.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import S, I\n",
      " |      \n",
      " |      >>> sorted([S(1)/2, I, -I], key=lambda x: x.sort_key())\n",
      " |      [1/2, -I, I]\n",
      " |      \n",
      " |      >>> S(\"[x, 1/x, 1/x**2, x**2, x**(1/2), x**(1/4), x**(3/2)]\")\n",
      " |      [x, 1/x, x**(-2), x**2, sqrt(x), x**(1/4), x**(3/2)]\n",
      " |      >>> sorted(_, key=lambda x: x.sort_key())\n",
      " |      [x**(-2), 1/x, x**(1/4), sqrt(x), x, x**(3/2), x**2]\n",
      " |  \n",
      " |  subs(self, *args, **kwargs)\n",
      " |      Substitutes old for new in an expression after sympifying args.\n",
      " |      \n",
      " |      `args` is either:\n",
      " |        - two arguments, e.g. foo.subs(old, new)\n",
      " |        - one iterable argument, e.g. foo.subs(iterable). The iterable may be\n",
      " |           o an iterable container with (old, new) pairs. In this case the\n",
      " |             replacements are processed in the order given with successive\n",
      " |             patterns possibly affecting replacements already made.\n",
      " |           o a dict or set whose key/value items correspond to old/new pairs.\n",
      " |             In this case the old/new pairs will be sorted by op count and in\n",
      " |             case of a tie, by number of args and the default_sort_key. The\n",
      " |             resulting sorted list is then processed as an iterable container\n",
      " |             (see previous).\n",
      " |      \n",
      " |      If the keyword ``simultaneous`` is True, the subexpressions will not be\n",
      " |      evaluated until all the substitutions have been made.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import pi, exp, limit, oo\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x*y).subs(x, pi)\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).subs({x:pi, y:2})\n",
      " |      1 + 2*pi\n",
      " |      >>> (1 + x*y).subs([(x, pi), (y, 2)])\n",
      " |      1 + 2*pi\n",
      " |      >>> reps = [(y, x**2), (x, 2)]\n",
      " |      >>> (x + y).subs(reps)\n",
      " |      6\n",
      " |      >>> (x + y).subs(reversed(reps))\n",
      " |      x**2 + 2\n",
      " |      \n",
      " |      >>> (x**2 + x**4).subs(x**2, y)\n",
      " |      y**2 + y\n",
      " |      \n",
      " |      To replace only the x**2 but not the x**4, use xreplace:\n",
      " |      \n",
      " |      >>> (x**2 + x**4).xreplace({x**2: y})\n",
      " |      x**4 + y\n",
      " |      \n",
      " |      To delay evaluation until all substitutions have been made,\n",
      " |      set the keyword ``simultaneous`` to True:\n",
      " |      \n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)])\n",
      " |      0\n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)], simultaneous=True)\n",
      " |      nan\n",
      " |      \n",
      " |      This has the added feature of not allowing subsequent substitutions\n",
      " |      to affect those already made:\n",
      " |      \n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y})\n",
      " |      1\n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y}, simultaneous=True)\n",
      " |      y/(x + y)\n",
      " |      \n",
      " |      In order to obtain a canonical result, unordered iterables are\n",
      " |      sorted by count_op length, number of arguments and by the\n",
      " |      default_sort_key to break any ties. All other iterables are left\n",
      " |      unsorted.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, sin, cos\n",
      " |      >>> from sympy.abc import a, b, c, d, e\n",
      " |      \n",
      " |      >>> A = (sqrt(sin(2*x)), a)\n",
      " |      >>> B = (sin(2*x), b)\n",
      " |      >>> C = (cos(2*x), c)\n",
      " |      >>> D = (x, d)\n",
      " |      >>> E = (exp(x), e)\n",
      " |      \n",
      " |      >>> expr = sqrt(sin(2*x))*sin(exp(x)*x)*cos(2*x) + sin(2*x)\n",
      " |      \n",
      " |      >>> expr.subs(dict([A, B, C, D, E]))\n",
      " |      a*c*sin(d*e) + b\n",
      " |      \n",
      " |      The resulting expression represents a literal replacement of the\n",
      " |      old arguments with the new arguments. This may not reflect the\n",
      " |      limiting behavior of the expression:\n",
      " |      \n",
      " |      >>> (x**3 - 3*x).subs({x: oo})\n",
      " |      nan\n",
      " |      \n",
      " |      >>> limit(x**3 - 3*x, x, oo)\n",
      " |      oo\n",
      " |      \n",
      " |      If the substitution will be followed by numerical\n",
      " |      evaluation, it is better to pass the substitution to\n",
      " |      evalf as\n",
      " |      \n",
      " |      >>> (1/x).evalf(subs={x: 3.0}, n=21)\n",
      " |      0.333333333333333333333\n",
      " |      \n",
      " |      rather than\n",
      " |      \n",
      " |      >>> (1/x).subs({x: 3.0}).evalf(21)\n",
      " |      0.333333333333333314830\n",
      " |      \n",
      " |      as the former will ensure that the desired level of precision is\n",
      " |      obtained.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |      sympy.core.evalf.EvalfMixin.evalf: calculates the given formula to a desired level of precision\n",
      " |  \n",
      " |  xreplace(self, rule)\n",
      " |      Replace occurrences of objects within the expression.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      rule : dict-like\n",
      " |          Expresses a replacement rule\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      xreplace : the result of the replacement\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, pi, exp\n",
      " |      >>> x, y, z = symbols('x y z')\n",
      " |      >>> (1 + x*y).xreplace({x: pi})\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).xreplace({x: pi, y: 2})\n",
      " |      1 + 2*pi\n",
      " |      \n",
      " |      Replacements occur only if an entire node in the expression tree is\n",
      " |      matched:\n",
      " |      \n",
      " |      >>> (x*y + z).xreplace({x*y: pi})\n",
      " |      z + pi\n",
      " |      >>> (x*y*z).xreplace({x*y: pi})\n",
      " |      x*y*z\n",
      " |      >>> (2*x).xreplace({2*x: y, x: z})\n",
      " |      y\n",
      " |      >>> (2*2*x).xreplace({2*x: y, x: z})\n",
      " |      4*z\n",
      " |      >>> (x + y + 2).xreplace({x + y: 2})\n",
      " |      x + y + 2\n",
      " |      >>> (x + 2 + exp(x + 2)).xreplace({x + 2: y})\n",
      " |      x + exp(y) + 2\n",
      " |      \n",
      " |      xreplace doesn't differentiate between free and bound symbols. In the\n",
      " |      following, subs(x, y) would not change x since it is a bound symbol,\n",
      " |      but xreplace does:\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> Integral(x, (x, 1, 2*x)).xreplace({x: y})\n",
      " |      Integral(y, (y, 1, 2*y))\n",
      " |      \n",
      " |      Trying to replace x with an expression raises an error:\n",
      " |      \n",
      " |      >>> Integral(x, (x, 1, 2*x)).xreplace({x: 2*y}) # doctest: +SKIP\n",
      " |      ValueError: Invalid limits given: ((2*y, 1, 4*y),)\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      subs: substitution of subexpressions as defined by the objects\n",
      " |            themselves.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  class_key() from sympy.core.assumptions.ManagedProperties\n",
      " |      Nice order of classes.\n",
      " |  \n",
      " |  fromiter(args, **assumptions) from sympy.core.assumptions.ManagedProperties\n",
      " |      Create a new object from an iterable.\n",
      " |      \n",
      " |      This is a convenience function that allows one to create objects from\n",
      " |      any iterable, without having to convert to a list or tuple first.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Tuple\n",
      " |      >>> Tuple.fromiter(i for i in range(5))\n",
      " |      (0, 1, 2, 3, 4)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  assumptions0\n",
      " |      Return object `type` assumptions.\n",
      " |      \n",
      " |      For example:\n",
      " |      \n",
      " |        Symbol('x', real=True)\n",
      " |        Symbol('x', integer=True)\n",
      " |      \n",
      " |      are different objects. In other words, besides Python type (Symbol in\n",
      " |      this case), the initial assumptions are also forming their typeinfo.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True}\n",
      " |      >>> x = Symbol(\"x\", positive=True)\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True, 'complex': True, 'extended_negative': False,\n",
      " |       'extended_nonnegative': True, 'extended_nonpositive': False,\n",
      " |       'extended_nonzero': True, 'extended_positive': True, 'extended_real':\n",
      " |       True, 'finite': True, 'hermitian': True, 'imaginary': False,\n",
      " |       'infinite': False, 'negative': False, 'nonnegative': True,\n",
      " |       'nonpositive': False, 'nonzero': True, 'positive': True, 'real':\n",
      " |       True, 'zero': False}\n",
      " |  \n",
      " |  canonical_variables\n",
      " |      Return a dictionary mapping any variable defined in\n",
      " |      ``self.bound_symbols`` to Symbols that do not clash\n",
      " |      with any free symbols in the expression.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> Lambda(x, 2*x).canonical_variables\n",
      " |      {x: _0}\n",
      " |  \n",
      " |  expr_free_symbols\n",
      " |  \n",
      " |  func\n",
      " |      The top-level function in an expression.\n",
      " |      \n",
      " |      The following should hold for all objects::\n",
      " |      \n",
      " |          >> x == x.func(*x.args)\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> a = 2*x\n",
      " |      >>> a.func\n",
      " |      <class 'sympy.core.mul.Mul'>\n",
      " |      >>> a.args\n",
      " |      (2, x)\n",
      " |      >>> a.func(*a.args)\n",
      " |      2*x\n",
      " |      >>> a == a.func(*a.args)\n",
      " |      True\n",
      " |  \n",
      " |  is_algebraic\n",
      " |  \n",
      " |  is_antihermitian\n",
      " |  \n",
      " |  is_comparable\n",
      " |      Return True if self can be computed to a real number\n",
      " |      (or already is a real number) with precision, else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import exp_polar, pi, I\n",
      " |      >>> (I*exp_polar(I*pi/2)).is_comparable\n",
      " |      True\n",
      " |      >>> (I*exp_polar(I*pi*2)).is_comparable\n",
      " |      False\n",
      " |      \n",
      " |      A False result does not mean that `self` cannot be rewritten\n",
      " |      into a form that would be comparable. For example, the\n",
      " |      difference computed below is zero but without simplification\n",
      " |      it does not evaluate to a zero with precision:\n",
      " |      \n",
      " |      >>> e = 2**pi*(1 + 2**pi)\n",
      " |      >>> dif = e - e.expand()\n",
      " |      >>> dif.is_comparable\n",
      " |      False\n",
      " |      >>> dif.n(2)._prec\n",
      " |      1\n",
      " |  \n",
      " |  is_complex\n",
      " |  \n",
      " |  is_composite\n",
      " |  \n",
      " |  is_even\n",
      " |  \n",
      " |  is_extended_negative\n",
      " |  \n",
      " |  is_extended_nonnegative\n",
      " |  \n",
      " |  is_extended_nonpositive\n",
      " |  \n",
      " |  is_extended_nonzero\n",
      " |  \n",
      " |  is_extended_positive\n",
      " |  \n",
      " |  is_extended_real\n",
      " |  \n",
      " |  is_finite\n",
      " |  \n",
      " |  is_hermitian\n",
      " |  \n",
      " |  is_imaginary\n",
      " |  \n",
      " |  is_infinite\n",
      " |  \n",
      " |  is_integer\n",
      " |  \n",
      " |  is_irrational\n",
      " |  \n",
      " |  is_negative\n",
      " |  \n",
      " |  is_noninteger\n",
      " |  \n",
      " |  is_nonnegative\n",
      " |  \n",
      " |  is_nonpositive\n",
      " |  \n",
      " |  is_nonzero\n",
      " |  \n",
      " |  is_odd\n",
      " |  \n",
      " |  is_polar\n",
      " |  \n",
      " |  is_positive\n",
      " |  \n",
      " |  is_prime\n",
      " |  \n",
      " |  is_rational\n",
      " |  \n",
      " |  is_real\n",
      " |  \n",
      " |  is_transcendental\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __annotations__ = {'_args': 'Tuple[Basic, ...]', '_mhash': 'Any', 'kin...\n",
      " |  \n",
      " |  is_Add = False\n",
      " |  \n",
      " |  is_AlgebraicNumber = False\n",
      " |  \n",
      " |  is_Atom = False\n",
      " |  \n",
      " |  is_Boolean = False\n",
      " |  \n",
      " |  is_Derivative = False\n",
      " |  \n",
      " |  is_Dummy = False\n",
      " |  \n",
      " |  is_Equality = False\n",
      " |  \n",
      " |  is_Float = False\n",
      " |  \n",
      " |  is_Function = False\n",
      " |  \n",
      " |  is_Indexed = False\n",
      " |  \n",
      " |  is_Integer = False\n",
      " |  \n",
      " |  is_MatAdd = False\n",
      " |  \n",
      " |  is_MatMul = False\n",
      " |  \n",
      " |  is_Matrix = False\n",
      " |  \n",
      " |  is_Mul = False\n",
      " |  \n",
      " |  is_Not = False\n",
      " |  \n",
      " |  is_Number = False\n",
      " |  \n",
      " |  is_NumberSymbol = False\n",
      " |  \n",
      " |  is_Order = False\n",
      " |  \n",
      " |  is_Piecewise = False\n",
      " |  \n",
      " |  is_Point = False\n",
      " |  \n",
      " |  is_Pow = False\n",
      " |  \n",
      " |  is_Rational = False\n",
      " |  \n",
      " |  is_Relational = False\n",
      " |  \n",
      " |  is_Symbol = False\n",
      " |  \n",
      " |  is_Vector = False\n",
      " |  \n",
      " |  is_Wild = False\n",
      " |  \n",
      " |  is_number = False\n",
      " |  \n",
      " |  is_symbol = False\n",
      " |  \n",
      " |  kind = UndefinedKind\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.printing.defaults.Printable:\n",
      " |  \n",
      " |  __repr__ = __str__(self)\n",
      " |  \n",
      " |  __str__(self)\n",
      " |      Return str(self).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(Poly)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "id": "1c3a4326",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{\\left( \\frac{4}{3}, \\  \\frac{3}{2}\\right)\\right\\}$"
      ],
      "text/plain": [
       "{(4/3, 3/2)}"
      ]
     },
     "execution_count": 198,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nonlinsolve([x+1/y-2,x*y-2],[x,y])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc19d99b-0dbb-4ff8-9009-54df2ff799e0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "fdd0be62",
   "metadata": {
    "collapsed": true,
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class ConditionSet in module sympy.sets.conditionset:\n",
      "\n",
      "class ConditionSet(sympy.sets.sets.Set)\n",
      " |  ConditionSet(sym, condition, base_set=UniversalSet)\n",
      " |  \n",
      " |  Set of elements which satisfies a given condition.\n",
      " |  \n",
      " |  .. math:: \\{x \\mid \\textrm{condition}(x) = \\texttt{True}, x \\in S\\}\n",
      " |  \n",
      " |  Examples\n",
      " |  ========\n",
      " |  \n",
      " |  >>> from sympy import Symbol, S, ConditionSet, pi, Eq, sin, Interval\n",
      " |  >>> from sympy.abc import x, y, z\n",
      " |  \n",
      " |  >>> sin_sols = ConditionSet(x, Eq(sin(x), 0), Interval(0, 2*pi))\n",
      " |  >>> 2*pi in sin_sols\n",
      " |  True\n",
      " |  >>> pi/2 in sin_sols\n",
      " |  False\n",
      " |  >>> 3*pi in sin_sols\n",
      " |  False\n",
      " |  >>> 5 in ConditionSet(x, x**2 > 4, S.Reals)\n",
      " |  True\n",
      " |  \n",
      " |  If the value is not in the base set, the result is false:\n",
      " |  \n",
      " |  >>> 5 in ConditionSet(x, x**2 > 4, Interval(2, 4))\n",
      " |  False\n",
      " |  \n",
      " |  Notes\n",
      " |  =====\n",
      " |  \n",
      " |  Symbols with assumptions should be avoided or else the\n",
      " |  condition may evaluate without consideration of the set:\n",
      " |  \n",
      " |  >>> n = Symbol('n', negative=True)\n",
      " |  >>> cond = (n > 0); cond\n",
      " |  False\n",
      " |  >>> ConditionSet(n, cond, S.Integers)\n",
      " |  EmptySet\n",
      " |  \n",
      " |  Only free symbols can be changed by using `subs`:\n",
      " |  \n",
      " |  >>> c = ConditionSet(x, x < 1, {x, z})\n",
      " |  >>> c.subs(x, y)\n",
      " |  ConditionSet(x, x < 1, {y, z})\n",
      " |  \n",
      " |  To check if ``pi`` is in ``c`` use:\n",
      " |  \n",
      " |  >>> pi in c\n",
      " |  False\n",
      " |  \n",
      " |  If no base set is specified, the universal set is implied:\n",
      " |  \n",
      " |  >>> ConditionSet(x, x < 1).base_set\n",
      " |  UniversalSet\n",
      " |  \n",
      " |  Only symbols or symbol-like expressions can be used:\n",
      " |  \n",
      " |  >>> ConditionSet(x + 1, x + 1 < 1, S.Integers)\n",
      " |  Traceback (most recent call last):\n",
      " |  ...\n",
      " |  ValueError: non-symbol dummy not recognized in condition\n",
      " |  \n",
      " |  When the base set is a ConditionSet, the symbols will be\n",
      " |  unified if possible with preference for the outermost symbols:\n",
      " |  \n",
      " |  >>> ConditionSet(x, x < y, ConditionSet(z, z + y < 2, S.Integers))\n",
      " |  ConditionSet(x, (x < y) & (x + y < 2), Integers)\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      ConditionSet\n",
      " |      sympy.sets.sets.Set\n",
      " |      sympy.core.basic.Basic\n",
      " |      sympy.printing.defaults.Printable\n",
      " |      sympy.core.evalf.EvalfMixin\n",
      " |      builtins.object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  as_relational(self, other)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  __new__(cls, sym, condition, base_set=UniversalSet)\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties defined here:\n",
      " |  \n",
      " |  __sympy__\n",
      " |  \n",
      " |  base_set\n",
      " |  \n",
      " |  bound_symbols\n",
      " |  \n",
      " |  condition\n",
      " |  \n",
      " |  free_symbols\n",
      " |      Return from the atoms of self those which are free symbols.\n",
      " |      \n",
      " |      For most expressions, all symbols are free symbols. For some classes\n",
      " |      this is not true. e.g. Integrals use Symbols for the dummy variables\n",
      " |      which are bound variables, so Integral has a method to return all\n",
      " |      symbols except those. Derivative keeps track of symbols with respect\n",
      " |      to which it will perform a derivative; those are\n",
      " |      bound variables, too, so it has its own free_symbols method.\n",
      " |      \n",
      " |      Any other method that uses bound variables should implement a\n",
      " |      free_symbols method.\n",
      " |  \n",
      " |  sym\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes defined here:\n",
      " |  \n",
      " |  default_assumptions = {}\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.sets.sets.Set:\n",
      " |  \n",
      " |  __add__(self, other)\n",
      " |  \n",
      " |  __and__(self, other)\n",
      " |  \n",
      " |  __contains__(self, other)\n",
      " |  \n",
      " |  __mul__(self, other)\n",
      " |  \n",
      " |  __or__(self, other)\n",
      " |  \n",
      " |  __pow__(self, exp)\n",
      " |  \n",
      " |  __sub__(self, other)\n",
      " |  \n",
      " |  __xor__(self, other)\n",
      " |  \n",
      " |  complement(self, universe)\n",
      " |      The complement of 'self' w.r.t the given universe.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, S\n",
      " |      >>> Interval(0, 1).complement(S.Reals)\n",
      " |      Union(Interval.open(-oo, 0), Interval.open(1, oo))\n",
      " |      \n",
      " |      >>> Interval(0, 1).complement(S.UniversalSet)\n",
      " |      Complement(UniversalSet, Interval(0, 1))\n",
      " |  \n",
      " |  contains(self, other)\n",
      " |      Returns a SymPy value indicating whether ``other`` is contained\n",
      " |      in ``self``: ``true`` if it is, ``false`` if it isn't, else\n",
      " |      an unevaluated ``Contains`` expression (or, as in the case of\n",
      " |      ConditionSet and a union of FiniteSet/Intervals, an expression\n",
      " |      indicating the conditions for containment).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, S\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Interval(0, 1).contains(0.5)\n",
      " |      True\n",
      " |      \n",
      " |      As a shortcut it is possible to use the ``in`` operator, but that\n",
      " |      will raise an error unless an affirmative true or false is not\n",
      " |      obtained.\n",
      " |      \n",
      " |      >>> Interval(0, 1).contains(x)\n",
      " |      (0 <= x) & (x <= 1)\n",
      " |      >>> x in Interval(0, 1)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      TypeError: did not evaluate to a bool: None\n",
      " |      \n",
      " |      The result of 'in' is a bool, not a SymPy value\n",
      " |      \n",
      " |      >>> 1 in Interval(0, 2)\n",
      " |      True\n",
      " |      >>> _ is S.true\n",
      " |      False\n",
      " |  \n",
      " |  intersect(self, other)\n",
      " |      Returns the intersection of 'self' and 'other'.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      \n",
      " |      >>> Interval(1, 3).intersect(Interval(1, 2))\n",
      " |      Interval(1, 2)\n",
      " |      \n",
      " |      >>> from sympy import imageset, Lambda, symbols, S\n",
      " |      >>> n, m = symbols('n m')\n",
      " |      >>> a = imageset(Lambda(n, 2*n), S.Integers)\n",
      " |      >>> a.intersect(imageset(Lambda(m, 2*m + 1), S.Integers))\n",
      " |      EmptySet\n",
      " |  \n",
      " |  intersection(self, other)\n",
      " |      Alias for :meth:`intersect()`\n",
      " |  \n",
      " |  is_disjoint(self, other)\n",
      " |      Returns True if ``self`` and ``other`` are disjoint.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 2).is_disjoint(Interval(1, 2))\n",
      " |      False\n",
      " |      >>> Interval(0, 2).is_disjoint(Interval(3, 4))\n",
      " |      True\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Disjoint_sets\n",
      " |  \n",
      " |  is_proper_subset(self, other)\n",
      " |      Returns True if ``self`` is a proper subset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 0.5).is_proper_subset(Interval(0, 1))\n",
      " |      True\n",
      " |      >>> Interval(0, 1).is_proper_subset(Interval(0, 1))\n",
      " |      False\n",
      " |  \n",
      " |  is_proper_superset(self, other)\n",
      " |      Returns True if ``self`` is a proper superset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).is_proper_superset(Interval(0, 0.5))\n",
      " |      True\n",
      " |      >>> Interval(0, 1).is_proper_superset(Interval(0, 1))\n",
      " |      False\n",
      " |  \n",
      " |  is_subset(self, other)\n",
      " |      Returns True if ``self`` is a subset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 0.5).is_subset(Interval(0, 1))\n",
      " |      True\n",
      " |      >>> Interval(0, 1).is_subset(Interval(0, 1, left_open=True))\n",
      " |      False\n",
      " |  \n",
      " |  is_superset(self, other)\n",
      " |      Returns True if ``self`` is a superset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 0.5).is_superset(Interval(0, 1))\n",
      " |      False\n",
      " |      >>> Interval(0, 1).is_superset(Interval(0, 1, left_open=True))\n",
      " |      True\n",
      " |  \n",
      " |  isdisjoint(self, other)\n",
      " |      Alias for :meth:`is_disjoint()`\n",
      " |  \n",
      " |  issubset(self, other)\n",
      " |      Alias for :meth:`is_subset()`\n",
      " |  \n",
      " |  issuperset(self, other)\n",
      " |      Alias for :meth:`is_superset()`\n",
      " |  \n",
      " |  powerset(self)\n",
      " |      Find the Power set of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import EmptySet, FiniteSet, Interval\n",
      " |      \n",
      " |      A power set of an empty set:\n",
      " |      \n",
      " |      >>> A = EmptySet\n",
      " |      >>> A.powerset()\n",
      " |      {EmptySet}\n",
      " |      \n",
      " |      A power set of a finite set:\n",
      " |      \n",
      " |      >>> A = FiniteSet(1, 2)\n",
      " |      >>> a, b, c = FiniteSet(1), FiniteSet(2), FiniteSet(1, 2)\n",
      " |      >>> A.powerset() == FiniteSet(a, b, c, EmptySet)\n",
      " |      True\n",
      " |      \n",
      " |      A power set of an interval:\n",
      " |      \n",
      " |      >>> Interval(1, 2).powerset()\n",
      " |      PowerSet(Interval(1, 2))\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Power_set\n",
      " |  \n",
      " |  symmetric_difference(self, other)\n",
      " |      Returns symmetric difference of ``self`` and ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, S\n",
      " |      >>> Interval(1, 3).symmetric_difference(S.Reals)\n",
      " |      Union(Interval.open(-oo, 1), Interval.open(3, oo))\n",
      " |      >>> Interval(1, 10).symmetric_difference(S.Reals)\n",
      " |      Union(Interval.open(-oo, 1), Interval.open(10, oo))\n",
      " |      \n",
      " |      >>> from sympy import S, EmptySet\n",
      " |      >>> S.Reals.symmetric_difference(EmptySet)\n",
      " |      Reals\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      .. [1] https://en.wikipedia.org/wiki/Symmetric_difference\n",
      " |  \n",
      " |  union(self, other)\n",
      " |      Returns the union of ``self`` and ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      As a shortcut it is possible to use the ``+`` operator:\n",
      " |      \n",
      " |      >>> from sympy import Interval, FiniteSet\n",
      " |      >>> Interval(0, 1).union(Interval(2, 3))\n",
      " |      Union(Interval(0, 1), Interval(2, 3))\n",
      " |      >>> Interval(0, 1) + Interval(2, 3)\n",
      " |      Union(Interval(0, 1), Interval(2, 3))\n",
      " |      >>> Interval(1, 2, True, True) + FiniteSet(2, 3)\n",
      " |      Union({3}, Interval.Lopen(1, 2))\n",
      " |      \n",
      " |      Similarly it is possible to use the ``-`` operator for set differences:\n",
      " |      \n",
      " |      >>> Interval(0, 2) - Interval(0, 1)\n",
      " |      Interval.Lopen(1, 2)\n",
      " |      >>> Interval(1, 3) - FiniteSet(2)\n",
      " |      Union(Interval.Ropen(1, 2), Interval.Lopen(2, 3))\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.sets.sets.Set:\n",
      " |  \n",
      " |  boundary\n",
      " |      The boundary or frontier of a set.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A point x is on the boundary of a set S if\n",
      " |      \n",
      " |      1.  x is in the closure of S.\n",
      " |          I.e. Every neighborhood of x contains a point in S.\n",
      " |      2.  x is not in the interior of S.\n",
      " |          I.e. There does not exist an open set centered on x contained\n",
      " |          entirely within S.\n",
      " |      \n",
      " |      There are the points on the outer rim of S.  If S is open then these\n",
      " |      points need not actually be contained within S.\n",
      " |      \n",
      " |      For example, the boundary of an interval is its start and end points.\n",
      " |      This is true regardless of whether or not the interval is open.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).boundary\n",
      " |      {0, 1}\n",
      " |      >>> Interval(0, 1, True, False).boundary\n",
      " |      {0, 1}\n",
      " |  \n",
      " |  closure\n",
      " |      Property method which returns the closure of a set.\n",
      " |      The closure is defined as the union of the set itself and its\n",
      " |      boundary.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import S, Interval\n",
      " |      >>> S.Reals.closure\n",
      " |      Reals\n",
      " |      >>> Interval(0, 1).closure\n",
      " |      Interval(0, 1)\n",
      " |  \n",
      " |  inf\n",
      " |      The infimum of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, Union\n",
      " |      >>> Interval(0, 1).inf\n",
      " |      0\n",
      " |      >>> Union(Interval(0, 1), Interval(2, 3)).inf\n",
      " |      0\n",
      " |  \n",
      " |  interior\n",
      " |      Property method which returns the interior of a set.\n",
      " |      The interior of a set S consists all points of S that do not\n",
      " |      belong to the boundary of S.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).interior\n",
      " |      Interval.open(0, 1)\n",
      " |      >>> Interval(0, 1).boundary.interior\n",
      " |      EmptySet\n",
      " |  \n",
      " |  is_EmptySet\n",
      " |  \n",
      " |  is_closed\n",
      " |      A property method to check whether a set is closed.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A set is closed if its complement is an open set. The closedness of a\n",
      " |      subset of the reals is determined with respect to R and its standard\n",
      " |      topology.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).is_closed\n",
      " |      True\n",
      " |  \n",
      " |  is_open\n",
      " |      Property method to check whether a set is open.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A set is open if and only if it has an empty intersection with its\n",
      " |      boundary. In particular, a subset A of the reals is open if and only\n",
      " |      if each one of its points is contained in an open interval that is a\n",
      " |      subset of A.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import S\n",
      " |      >>> S.Reals.is_open\n",
      " |      True\n",
      " |      >>> S.Rationals.is_open\n",
      " |      False\n",
      " |  \n",
      " |  measure\n",
      " |      The (Lebesgue) measure of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, Union\n",
      " |      >>> Interval(0, 1).measure\n",
      " |      1\n",
      " |      >>> Union(Interval(0, 1), Interval(2, 3)).measure\n",
      " |      2\n",
      " |  \n",
      " |  sup\n",
      " |      The supremum of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, Union\n",
      " |      >>> Interval(0, 1).sup\n",
      " |      1\n",
      " |      >>> Union(Interval(0, 1), Interval(2, 3)).sup\n",
      " |      3\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from sympy.sets.sets.Set:\n",
      " |  \n",
      " |  __dict__\n",
      " |      dictionary for instance variables (if defined)\n",
      " |  \n",
      " |  __weakref__\n",
      " |      list of weak references to the object (if defined)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.sets.sets.Set:\n",
      " |  \n",
      " |  is_Complement = None\n",
      " |  \n",
      " |  is_ComplexRegion = False\n",
      " |  \n",
      " |  is_FiniteSet = False\n",
      " |  \n",
      " |  is_Intersection = None\n",
      " |  \n",
      " |  is_Interval = False\n",
      " |  \n",
      " |  is_ProductSet = False\n",
      " |  \n",
      " |  is_Union = False\n",
      " |  \n",
      " |  is_UniversalSet = None\n",
      " |  \n",
      " |  is_empty = None\n",
      " |  \n",
      " |  is_finite_set = None\n",
      " |  \n",
      " |  is_interval = False\n",
      " |  \n",
      " |  is_iterable = False\n",
      " |  \n",
      " |  is_number = False\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __eq__(self, other)\n",
      " |      Return a boolean indicating whether a == b on the basis of\n",
      " |      their symbolic trees.\n",
      " |      \n",
      " |      This is the same as a.compare(b) == 0 but faster.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      If a class that overrides __eq__() needs to retain the\n",
      " |      implementation of __hash__() from a parent class, the\n",
      " |      interpreter must be told this explicitly by setting\n",
      " |      __hash__ : Callable[[object], int] = <ParentClass>.__hash__.\n",
      " |      Otherwise the inheritance of __hash__() will be blocked,\n",
      " |      just as if __hash__ had been explicitly set to None.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      from http://docs.python.org/dev/reference/datamodel.html#object.__hash__\n",
      " |  \n",
      " |  __getnewargs__(self)\n",
      " |  \n",
      " |  __getstate__(self)\n",
      " |  \n",
      " |  __hash__(self) -> int\n",
      " |      Return hash(self).\n",
      " |  \n",
      " |  __ne__(self, other)\n",
      " |      ``a != b``  -> Compare two symbolic trees and see whether they are different\n",
      " |      \n",
      " |      this is the same as:\n",
      " |      \n",
      " |      ``a.compare(b) != 0``\n",
      " |      \n",
      " |      but faster\n",
      " |  \n",
      " |  __reduce_ex__(self, protocol)\n",
      " |      Helper for pickle.\n",
      " |  \n",
      " |  __setstate__(self, state)\n",
      " |  \n",
      " |  as_content_primitive(self, radical=False, clear=True)\n",
      " |      A stub to allow Basic args (like Tuple) to be skipped when computing\n",
      " |      the content and primitive components of an expression.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.core.expr.Expr.as_content_primitive\n",
      " |  \n",
      " |  as_dummy(self)\n",
      " |      Return the expression with any objects having structurally\n",
      " |      bound symbols replaced with unique, canonical symbols within\n",
      " |      the object in which they appear and having only the default\n",
      " |      assumption for commutativity being True. When applied to a\n",
      " |      symbol a new symbol having only the same commutativity will be\n",
      " |      returned.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> r = Symbol('r', real=True)\n",
      " |      >>> Integral(r, (r, x)).as_dummy()\n",
      " |      Integral(_0, (_0, x))\n",
      " |      >>> _.variables[0].is_real is None\n",
      " |      True\n",
      " |      >>> r.as_dummy()\n",
      " |      _r\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Any object that has structurally bound variables should have\n",
      " |      a property, `bound_symbols` that returns those symbols\n",
      " |      appearing in the object.\n",
      " |  \n",
      " |  atoms(self, *types)\n",
      " |      Returns the atoms that form the current object.\n",
      " |      \n",
      " |      By default, only objects that are truly atomic and cannot\n",
      " |      be divided into smaller pieces are returned: symbols, numbers,\n",
      " |      and number symbols like I and pi. It is possible to request\n",
      " |      atoms of any type, however, as demonstrated below.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import I, pi, sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms()\n",
      " |      {1, 2, I, pi, x, y}\n",
      " |      \n",
      " |      If one or more types are given, the results will contain only\n",
      " |      those types of atoms.\n",
      " |      \n",
      " |      >>> from sympy import Number, NumberSymbol, Symbol\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Symbol)\n",
      " |      {x, y}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number)\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol)\n",
      " |      {1, 2, pi}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol, I)\n",
      " |      {1, 2, I, pi}\n",
      " |      \n",
      " |      Note that I (imaginary unit) and zoo (complex infinity) are special\n",
      " |      types of number symbols and are not part of the NumberSymbol class.\n",
      " |      \n",
      " |      The type can be given implicitly, too:\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(x) # x is a Symbol\n",
      " |      {x, y}\n",
      " |      \n",
      " |      Be careful to check your assumptions when using the implicit option\n",
      " |      since ``S(1).is_Integer = True`` but ``type(S(1))`` is ``One``, a special type\n",
      " |      of SymPy atom, while ``type(S(2))`` is type ``Integer`` and will find all\n",
      " |      integers in an expression:\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(1))\n",
      " |      {1}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(2))\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      Finally, arguments to atoms() can select more than atomic atoms: any\n",
      " |      SymPy type (loaded in core/__init__.py) can be listed as an argument\n",
      " |      and those types of \"atoms\" as found in scanning the arguments of the\n",
      " |      expression recursively:\n",
      " |      \n",
      " |      >>> from sympy import Function, Mul\n",
      " |      >>> from sympy.core.function import AppliedUndef\n",
      " |      >>> f = Function('f')\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(Function)\n",
      " |      {f(x), sin(y + I*pi)}\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(AppliedUndef)\n",
      " |      {f(x)}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Mul)\n",
      " |      {I*pi, 2*sin(y + I*pi)}\n",
      " |  \n",
      " |  compare(self, other)\n",
      " |      Return -1, 0, 1 if the object is smaller, equal, or greater than other.\n",
      " |      \n",
      " |      Not in the mathematical sense. If the object is of a different type\n",
      " |      from the \"other\" then their classes are ordered according to\n",
      " |      the sorted_classes list.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> x.compare(y)\n",
      " |      -1\n",
      " |      >>> x.compare(x)\n",
      " |      0\n",
      " |      >>> y.compare(x)\n",
      " |      1\n",
      " |  \n",
      " |  copy(self)\n",
      " |  \n",
      " |  could_extract_minus_sign(self)\n",
      " |  \n",
      " |  count(self, query)\n",
      " |      Count the number of matching subexpressions.\n",
      " |  \n",
      " |  count_ops(self, visual=None)\n",
      " |      wrapper for count_ops that returns the operation count.\n",
      " |  \n",
      " |  doit(self, **hints)\n",
      " |      Evaluate objects that are not evaluated by default like limits,\n",
      " |      integrals, sums and products. All objects of this kind will be\n",
      " |      evaluated recursively, unless some species were excluded via 'hints'\n",
      " |      or unless the 'deep' hint was set to 'False'.\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> 2*Integral(x, x)\n",
      " |      2*Integral(x, x)\n",
      " |      \n",
      " |      >>> (2*Integral(x, x)).doit()\n",
      " |      x**2\n",
      " |      \n",
      " |      >>> (2*Integral(x, x)).doit(deep=False)\n",
      " |      2*Integral(x, x)\n",
      " |  \n",
      " |  dummy_eq(self, other, symbol=None)\n",
      " |      Compare two expressions and handle dummy symbols.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Dummy\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> u = Dummy('u')\n",
      " |      \n",
      " |      >>> (u**2 + 1).dummy_eq(x**2 + 1)\n",
      " |      True\n",
      " |      >>> (u**2 + 1) == (x**2 + 1)\n",
      " |      False\n",
      " |      \n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, x)\n",
      " |      True\n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, y)\n",
      " |      False\n",
      " |  \n",
      " |  find(self, query, group=False)\n",
      " |      Find all subexpressions matching a query.\n",
      " |  \n",
      " |  has(self, *patterns)\n",
      " |      Test whether any subexpression matches any of the patterns.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x**2 + sin(x*y)).has(z)\n",
      " |      False\n",
      " |      >>> (x**2 + sin(x*y)).has(x, y, z)\n",
      " |      True\n",
      " |      >>> x.has(x)\n",
      " |      True\n",
      " |      \n",
      " |      Note ``has`` is a structural algorithm with no knowledge of\n",
      " |      mathematics. Consider the following half-open interval:\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> i = Interval.Lopen(0, 5); i\n",
      " |      Interval.Lopen(0, 5)\n",
      " |      >>> i.args\n",
      " |      (0, 5, True, False)\n",
      " |      >>> i.has(4)  # there is no \"4\" in the arguments\n",
      " |      False\n",
      " |      >>> i.has(0)  # there *is* a \"0\" in the arguments\n",
      " |      True\n",
      " |      \n",
      " |      Instead, use ``contains`` to determine whether a number is in the\n",
      " |      interval or not:\n",
      " |      \n",
      " |      >>> i.contains(4)\n",
      " |      True\n",
      " |      >>> i.contains(0)\n",
      " |      False\n",
      " |      \n",
      " |      \n",
      " |      Note that ``expr.has(*patterns)`` is exactly equivalent to\n",
      " |      ``any(expr.has(p) for p in patterns)``. In particular, ``False`` is\n",
      " |      returned when the list of patterns is empty.\n",
      " |      \n",
      " |      >>> x.has()\n",
      " |      False\n",
      " |  \n",
      " |  has_free(self, *patterns)\n",
      " |      return True if self has object(s) ``x`` as a free expression\n",
      " |      else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Function\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = Function('f')\n",
      " |      >>> g = Function('g')\n",
      " |      >>> expr = Integral(f(x), (f(x), 1, g(y)))\n",
      " |      >>> expr.free_symbols\n",
      " |      {y}\n",
      " |      >>> expr.has_free(g(y))\n",
      " |      True\n",
      " |      >>> expr.has_free(*(x, f(x)))\n",
      " |      False\n",
      " |      \n",
      " |      This works for subexpressions and types, too:\n",
      " |      \n",
      " |      >>> expr.has_free(g)\n",
      " |      True\n",
      " |      >>> (x + y + 1).has_free(y + 1)\n",
      " |      True\n",
      " |  \n",
      " |  is_hypergeometric(self, k)\n",
      " |  \n",
      " |  match(self, pattern, old=False)\n",
      " |      Pattern matching.\n",
      " |      \n",
      " |      Wild symbols match all.\n",
      " |      \n",
      " |      Return ``None`` when expression (self) does not match\n",
      " |      with pattern. Otherwise return a dictionary such that::\n",
      " |      \n",
      " |        pattern.xreplace(self.match(pattern)) == self\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Wild, Sum\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> p = Wild(\"p\")\n",
      " |      >>> q = Wild(\"q\")\n",
      " |      >>> r = Wild(\"r\")\n",
      " |      >>> e = (x+y)**(x+y)\n",
      " |      >>> e.match(p**p)\n",
      " |      {p_: x + y}\n",
      " |      >>> e.match(p**q)\n",
      " |      {p_: x + y, q_: x + y}\n",
      " |      >>> e = (2*x)**2\n",
      " |      >>> e.match(p*q**r)\n",
      " |      {p_: 4, q_: x, r_: 2}\n",
      " |      >>> (p*q**r).xreplace(e.match(p*q**r))\n",
      " |      4*x**2\n",
      " |      \n",
      " |      Structurally bound symbols are ignored during matching:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(y, (y, 1, p)))\n",
      " |      {p_: 2}\n",
      " |      \n",
      " |      But they can be identified if desired:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(q, (q, 1, p)))\n",
      " |      {p_: 2, q_: x}\n",
      " |      \n",
      " |      The ``old`` flag will give the old-style pattern matching where\n",
      " |      expressions and patterns are essentially solved to give the\n",
      " |      match. Both of the following give None unless ``old=True``:\n",
      " |      \n",
      " |      >>> (x - 2).match(p - x, old=True)\n",
      " |      {p_: 2*x - 2}\n",
      " |      >>> (2/x).match(p*x, old=True)\n",
      " |      {p_: 2/x**2}\n",
      " |  \n",
      " |  matches(self, expr, repl_dict=None, old=False)\n",
      " |      Helper method for match() that looks for a match between Wild symbols\n",
      " |      in self and expressions in expr.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, Wild, Basic\n",
      " |      >>> a, b, c = symbols('a b c')\n",
      " |      >>> x = Wild('x')\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b, c)) is None\n",
      " |      True\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b + c, b + c))\n",
      " |      {x_: b + c}\n",
      " |  \n",
      " |  rcall(self, *args)\n",
      " |      Apply on the argument recursively through the expression tree.\n",
      " |      \n",
      " |      This method is used to simulate a common abuse of notation for\n",
      " |      operators. For instance, in SymPy the following will not work:\n",
      " |      \n",
      " |      ``(x+Lambda(y, 2*y))(z) == x+2*z``,\n",
      " |      \n",
      " |      however, you can use:\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x + Lambda(y, 2*y)).rcall(z)\n",
      " |      x + 2*z\n",
      " |  \n",
      " |  refine(self, assumption=True)\n",
      " |      See the refine function in sympy.assumptions\n",
      " |  \n",
      " |  replace(self, query, value, map=False, simultaneous=True, exact=None)\n",
      " |      Replace matching subexpressions of ``self`` with ``value``.\n",
      " |      \n",
      " |      If ``map = True`` then also return the mapping {old: new} where ``old``\n",
      " |      was a sub-expression found with query and ``new`` is the replacement\n",
      " |      value for it. If the expression itself doesn't match the query, then\n",
      " |      the returned value will be ``self.xreplace(map)`` otherwise it should\n",
      " |      be ``self.subs(ordered(map.items()))``.\n",
      " |      \n",
      " |      Traverses an expression tree and performs replacement of matching\n",
      " |      subexpressions from the bottom to the top of the tree. The default\n",
      " |      approach is to do the replacement in a simultaneous fashion so\n",
      " |      changes made are targeted only once. If this is not desired or causes\n",
      " |      problems, ``simultaneous`` can be set to False.\n",
      " |      \n",
      " |      In addition, if an expression containing more than one Wild symbol\n",
      " |      is being used to match subexpressions and the ``exact`` flag is None\n",
      " |      it will be set to True so the match will only succeed if all non-zero\n",
      " |      values are received for each Wild that appears in the match pattern.\n",
      " |      Setting this to False accepts a match of 0; while setting it True\n",
      " |      accepts all matches that have a 0 in them. See example below for\n",
      " |      cautions.\n",
      " |      \n",
      " |      The list of possible combinations of queries and replacement values\n",
      " |      is listed below:\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      Initial setup\n",
      " |      \n",
      " |      >>> from sympy import log, sin, cos, tan, Wild, Mul, Add\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = log(sin(x)) + tan(sin(x**2))\n",
      " |      \n",
      " |      1.1. type -> type\n",
      " |          obj.replace(type, newtype)\n",
      " |      \n",
      " |          When object of type ``type`` is found, replace it with the\n",
      " |          result of passing its argument(s) to ``newtype``.\n",
      " |      \n",
      " |          >>> f.replace(sin, cos)\n",
      " |          log(cos(x)) + tan(cos(x**2))\n",
      " |          >>> sin(x).replace(sin, cos, map=True)\n",
      " |          (cos(x), {sin(x): cos(x)})\n",
      " |          >>> (x*y).replace(Mul, Add)\n",
      " |          x + y\n",
      " |      \n",
      " |      1.2. type -> func\n",
      " |          obj.replace(type, func)\n",
      " |      \n",
      " |          When object of type ``type`` is found, apply ``func`` to its\n",
      " |          argument(s). ``func`` must be written to handle the number\n",
      " |          of arguments of ``type``.\n",
      " |      \n",
      " |          >>> f.replace(sin, lambda arg: sin(2*arg))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |          >>> (x*y).replace(Mul, lambda *args: sin(2*Mul(*args)))\n",
      " |          sin(2*x*y)\n",
      " |      \n",
      " |      2.1. pattern -> expr\n",
      " |          obj.replace(pattern(wild), expr(wild))\n",
      " |      \n",
      " |          Replace subexpressions matching ``pattern`` with the expression\n",
      " |          written in terms of the Wild symbols in ``pattern``.\n",
      " |      \n",
      " |          >>> a, b = map(Wild, 'ab')\n",
      " |          >>> f.replace(sin(a), tan(a))\n",
      " |          log(tan(x)) + tan(tan(x**2))\n",
      " |          >>> f.replace(sin(a), tan(a/2))\n",
      " |          log(tan(x/2)) + tan(tan(x**2/2))\n",
      " |          >>> f.replace(sin(a), a)\n",
      " |          log(x) + tan(x**2)\n",
      " |          >>> (x*y).replace(a*x, a)\n",
      " |          y\n",
      " |      \n",
      " |          Matching is exact by default when more than one Wild symbol\n",
      " |          is used: matching fails unless the match gives non-zero\n",
      " |          values for all Wild symbols:\n",
      " |      \n",
      " |          >>> (2*x + y).replace(a*x + b, b - a)\n",
      " |          y - 2\n",
      " |          >>> (2*x).replace(a*x + b, b - a)\n",
      " |          2*x\n",
      " |      \n",
      " |          When set to False, the results may be non-intuitive:\n",
      " |      \n",
      " |          >>> (2*x).replace(a*x + b, b - a, exact=False)\n",
      " |          2/x\n",
      " |      \n",
      " |      2.2. pattern -> func\n",
      " |          obj.replace(pattern(wild), lambda wild: expr(wild))\n",
      " |      \n",
      " |          All behavior is the same as in 2.1 but now a function in terms of\n",
      " |          pattern variables is used rather than an expression:\n",
      " |      \n",
      " |          >>> f.replace(sin(a), lambda a: sin(2*a))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |      \n",
      " |      3.1. func -> func\n",
      " |          obj.replace(filter, func)\n",
      " |      \n",
      " |          Replace subexpression ``e`` with ``func(e)`` if ``filter(e)``\n",
      " |          is True.\n",
      " |      \n",
      " |          >>> g = 2*sin(x**3)\n",
      " |          >>> g.replace(lambda expr: expr.is_Number, lambda expr: expr**2)\n",
      " |          4*sin(x**9)\n",
      " |      \n",
      " |      The expression itself is also targeted by the query but is done in\n",
      " |      such a fashion that changes are not made twice.\n",
      " |      \n",
      " |          >>> e = x*(x*y + 1)\n",
      " |          >>> e.replace(lambda x: x.is_Mul, lambda x: 2*x)\n",
      " |          2*x*(2*x*y + 1)\n",
      " |      \n",
      " |      When matching a single symbol, `exact` will default to True, but\n",
      " |      this may or may not be the behavior that is desired:\n",
      " |      \n",
      " |      Here, we want `exact=False`:\n",
      " |      \n",
      " |      >>> from sympy import Function\n",
      " |      >>> f = Function('f')\n",
      " |      >>> e = f(1) + f(0)\n",
      " |      >>> q = f(a), lambda a: f(a + 1)\n",
      " |      >>> e.replace(*q, exact=False)\n",
      " |      f(1) + f(2)\n",
      " |      >>> e.replace(*q, exact=True)\n",
      " |      f(0) + f(2)\n",
      " |      \n",
      " |      But here, the nature of matching makes selecting\n",
      " |      the right setting tricky:\n",
      " |      \n",
      " |      >>> e = x**(1 + y)\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(-x - y + 1)\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(1 - y)\n",
      " |      \n",
      " |      It is probably better to use a different form of the query\n",
      " |      that describes the target expression more precisely:\n",
      " |      \n",
      " |      >>> (1 + x**(1 + y)).replace(\n",
      " |      ... lambda x: x.is_Pow and x.exp.is_Add and x.exp.args[0] == 1,\n",
      " |      ... lambda x: x.base**(1 - (x.exp - 1)))\n",
      " |      ...\n",
      " |      x**(1 - y) + 1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      subs: substitution of subexpressions as defined by the objects\n",
      " |            themselves.\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |  \n",
      " |  rewrite(self, *args, deep=True, **hints)\n",
      " |      Rewrite *self* using a defined rule.\n",
      " |      \n",
      " |      Rewriting transforms an expression to another, which is mathematically\n",
      " |      equivalent but structurally different. For example you can rewrite\n",
      " |      trigonometric functions as complex exponentials or combinatorial\n",
      " |      functions as gamma function.\n",
      " |      \n",
      " |      This method takes a *pattern* and a *rule* as positional arguments.\n",
      " |      *pattern* is optional parameter which defines the types of expressions\n",
      " |      that will be transformed. If it is not passed, all possible expressions\n",
      " |      will be rewritten. *rule* defines how the expression will be rewritten.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      args : *rule*, or *pattern* and *rule*.\n",
      " |          - *pattern* is a type or an iterable of types.\n",
      " |          - *rule* can be any object.\n",
      " |      \n",
      " |      deep : bool, optional.\n",
      " |          If ``True``, subexpressions are recursively transformed. Default is\n",
      " |          ``True``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      If *pattern* is unspecified, all possible expressions are transformed.\n",
      " |      \n",
      " |      >>> from sympy import cos, sin, exp, I\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> expr = cos(x) + I*sin(x)\n",
      " |      >>> expr.rewrite(exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Pattern can be a type or an iterable of types.\n",
      " |      \n",
      " |      >>> expr.rewrite(sin, exp)\n",
      " |      exp(I*x)/2 + cos(x) - exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos,], exp)\n",
      " |      exp(I*x)/2 + I*sin(x) + exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos, sin], exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Rewriting behavior can be implemented by defining ``_eval_rewrite()``\n",
      " |      method.\n",
      " |      \n",
      " |      >>> from sympy import Expr, sqrt, pi\n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite(self, rule, args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         if rule == cos:\n",
      " |      ...             return cos(pi/2 - x, evaluate=False)\n",
      " |      ...         if rule == sqrt:\n",
      " |      ...             return sqrt(1 - cos(x)**2)\n",
      " |      >>> MySin(MySin(x)).rewrite(cos)\n",
      " |      cos(-cos(-x + pi/2) + pi/2)\n",
      " |      >>> MySin(x).rewrite(sqrt)\n",
      " |      sqrt(1 - cos(x)**2)\n",
      " |      \n",
      " |      Defining ``_eval_rewrite_as_[...]()`` method is supported for backwards\n",
      " |      compatibility reason. This may be removed in the future and using it is\n",
      " |      discouraged.\n",
      " |      \n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite_as_cos(self, *args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         return cos(pi/2 - x, evaluate=False)\n",
      " |      >>> MySin(x).rewrite(cos)\n",
      " |      cos(-x + pi/2)\n",
      " |  \n",
      " |  simplify(self, **kwargs)\n",
      " |      See the simplify function in sympy.simplify\n",
      " |  \n",
      " |  sort_key(self, order=None)\n",
      " |      Return a sort key.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import S, I\n",
      " |      \n",
      " |      >>> sorted([S(1)/2, I, -I], key=lambda x: x.sort_key())\n",
      " |      [1/2, -I, I]\n",
      " |      \n",
      " |      >>> S(\"[x, 1/x, 1/x**2, x**2, x**(1/2), x**(1/4), x**(3/2)]\")\n",
      " |      [x, 1/x, x**(-2), x**2, sqrt(x), x**(1/4), x**(3/2)]\n",
      " |      >>> sorted(_, key=lambda x: x.sort_key())\n",
      " |      [x**(-2), 1/x, x**(1/4), sqrt(x), x, x**(3/2), x**2]\n",
      " |  \n",
      " |  subs(self, *args, **kwargs)\n",
      " |      Substitutes old for new in an expression after sympifying args.\n",
      " |      \n",
      " |      `args` is either:\n",
      " |        - two arguments, e.g. foo.subs(old, new)\n",
      " |        - one iterable argument, e.g. foo.subs(iterable). The iterable may be\n",
      " |           o an iterable container with (old, new) pairs. In this case the\n",
      " |             replacements are processed in the order given with successive\n",
      " |             patterns possibly affecting replacements already made.\n",
      " |           o a dict or set whose key/value items correspond to old/new pairs.\n",
      " |             In this case the old/new pairs will be sorted by op count and in\n",
      " |             case of a tie, by number of args and the default_sort_key. The\n",
      " |             resulting sorted list is then processed as an iterable container\n",
      " |             (see previous).\n",
      " |      \n",
      " |      If the keyword ``simultaneous`` is True, the subexpressions will not be\n",
      " |      evaluated until all the substitutions have been made.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import pi, exp, limit, oo\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x*y).subs(x, pi)\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).subs({x:pi, y:2})\n",
      " |      1 + 2*pi\n",
      " |      >>> (1 + x*y).subs([(x, pi), (y, 2)])\n",
      " |      1 + 2*pi\n",
      " |      >>> reps = [(y, x**2), (x, 2)]\n",
      " |      >>> (x + y).subs(reps)\n",
      " |      6\n",
      " |      >>> (x + y).subs(reversed(reps))\n",
      " |      x**2 + 2\n",
      " |      \n",
      " |      >>> (x**2 + x**4).subs(x**2, y)\n",
      " |      y**2 + y\n",
      " |      \n",
      " |      To replace only the x**2 but not the x**4, use xreplace:\n",
      " |      \n",
      " |      >>> (x**2 + x**4).xreplace({x**2: y})\n",
      " |      x**4 + y\n",
      " |      \n",
      " |      To delay evaluation until all substitutions have been made,\n",
      " |      set the keyword ``simultaneous`` to True:\n",
      " |      \n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)])\n",
      " |      0\n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)], simultaneous=True)\n",
      " |      nan\n",
      " |      \n",
      " |      This has the added feature of not allowing subsequent substitutions\n",
      " |      to affect those already made:\n",
      " |      \n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y})\n",
      " |      1\n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y}, simultaneous=True)\n",
      " |      y/(x + y)\n",
      " |      \n",
      " |      In order to obtain a canonical result, unordered iterables are\n",
      " |      sorted by count_op length, number of arguments and by the\n",
      " |      default_sort_key to break any ties. All other iterables are left\n",
      " |      unsorted.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, sin, cos\n",
      " |      >>> from sympy.abc import a, b, c, d, e\n",
      " |      \n",
      " |      >>> A = (sqrt(sin(2*x)), a)\n",
      " |      >>> B = (sin(2*x), b)\n",
      " |      >>> C = (cos(2*x), c)\n",
      " |      >>> D = (x, d)\n",
      " |      >>> E = (exp(x), e)\n",
      " |      \n",
      " |      >>> expr = sqrt(sin(2*x))*sin(exp(x)*x)*cos(2*x) + sin(2*x)\n",
      " |      \n",
      " |      >>> expr.subs(dict([A, B, C, D, E]))\n",
      " |      a*c*sin(d*e) + b\n",
      " |      \n",
      " |      The resulting expression represents a literal replacement of the\n",
      " |      old arguments with the new arguments. This may not reflect the\n",
      " |      limiting behavior of the expression:\n",
      " |      \n",
      " |      >>> (x**3 - 3*x).subs({x: oo})\n",
      " |      nan\n",
      " |      \n",
      " |      >>> limit(x**3 - 3*x, x, oo)\n",
      " |      oo\n",
      " |      \n",
      " |      If the substitution will be followed by numerical\n",
      " |      evaluation, it is better to pass the substitution to\n",
      " |      evalf as\n",
      " |      \n",
      " |      >>> (1/x).evalf(subs={x: 3.0}, n=21)\n",
      " |      0.333333333333333333333\n",
      " |      \n",
      " |      rather than\n",
      " |      \n",
      " |      >>> (1/x).subs({x: 3.0}).evalf(21)\n",
      " |      0.333333333333333314830\n",
      " |      \n",
      " |      as the former will ensure that the desired level of precision is\n",
      " |      obtained.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |      sympy.core.evalf.EvalfMixin.evalf: calculates the given formula to a desired level of precision\n",
      " |  \n",
      " |  xreplace(self, rule)\n",
      " |      Replace occurrences of objects within the expression.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      rule : dict-like\n",
      " |          Expresses a replacement rule\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      xreplace : the result of the replacement\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, pi, exp\n",
      " |      >>> x, y, z = symbols('x y z')\n",
      " |      >>> (1 + x*y).xreplace({x: pi})\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).xreplace({x: pi, y: 2})\n",
      " |      1 + 2*pi\n",
      " |      \n",
      " |      Replacements occur only if an entire node in the expression tree is\n",
      " |      matched:\n",
      " |      \n",
      " |      >>> (x*y + z).xreplace({x*y: pi})\n",
      " |      z + pi\n",
      " |      >>> (x*y*z).xreplace({x*y: pi})\n",
      " |      x*y*z\n",
      " |      >>> (2*x).xreplace({2*x: y, x: z})\n",
      " |      y\n",
      " |      >>> (2*2*x).xreplace({2*x: y, x: z})\n",
      " |      4*z\n",
      " |      >>> (x + y + 2).xreplace({x + y: 2})\n",
      " |      x + y + 2\n",
      " |      >>> (x + 2 + exp(x + 2)).xreplace({x + 2: y})\n",
      " |      x + exp(y) + 2\n",
      " |      \n",
      " |      xreplace doesn't differentiate between free and bound symbols. In the\n",
      " |      following, subs(x, y) would not change x since it is a bound symbol,\n",
      " |      but xreplace does:\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> Integral(x, (x, 1, 2*x)).xreplace({x: y})\n",
      " |      Integral(y, (y, 1, 2*y))\n",
      " |      \n",
      " |      Trying to replace x with an expression raises an error:\n",
      " |      \n",
      " |      >>> Integral(x, (x, 1, 2*x)).xreplace({x: 2*y}) # doctest: +SKIP\n",
      " |      ValueError: Invalid limits given: ((2*y, 1, 4*y),)\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      subs: substitution of subexpressions as defined by the objects\n",
      " |            themselves.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  class_key() from sympy.core.assumptions.ManagedProperties\n",
      " |      Nice order of classes.\n",
      " |  \n",
      " |  fromiter(args, **assumptions) from sympy.core.assumptions.ManagedProperties\n",
      " |      Create a new object from an iterable.\n",
      " |      \n",
      " |      This is a convenience function that allows one to create objects from\n",
      " |      any iterable, without having to convert to a list or tuple first.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Tuple\n",
      " |      >>> Tuple.fromiter(i for i in range(5))\n",
      " |      (0, 1, 2, 3, 4)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  args\n",
      " |      Returns a tuple of arguments of 'self'.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cot\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> cot(x).args\n",
      " |      (x,)\n",
      " |      \n",
      " |      >>> cot(x).args[0]\n",
      " |      x\n",
      " |      \n",
      " |      >>> (x*y).args\n",
      " |      (x, y)\n",
      " |      \n",
      " |      >>> (x*y).args[1]\n",
      " |      y\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Never use self._args, always use self.args.\n",
      " |      Only use _args in __new__ when creating a new function.\n",
      " |      Don't override .args() from Basic (so that it's easy to\n",
      " |      change the interface in the future if needed).\n",
      " |  \n",
      " |  assumptions0\n",
      " |      Return object `type` assumptions.\n",
      " |      \n",
      " |      For example:\n",
      " |      \n",
      " |        Symbol('x', real=True)\n",
      " |        Symbol('x', integer=True)\n",
      " |      \n",
      " |      are different objects. In other words, besides Python type (Symbol in\n",
      " |      this case), the initial assumptions are also forming their typeinfo.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True}\n",
      " |      >>> x = Symbol(\"x\", positive=True)\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True, 'complex': True, 'extended_negative': False,\n",
      " |       'extended_nonnegative': True, 'extended_nonpositive': False,\n",
      " |       'extended_nonzero': True, 'extended_positive': True, 'extended_real':\n",
      " |       True, 'finite': True, 'hermitian': True, 'imaginary': False,\n",
      " |       'infinite': False, 'negative': False, 'nonnegative': True,\n",
      " |       'nonpositive': False, 'nonzero': True, 'positive': True, 'real':\n",
      " |       True, 'zero': False}\n",
      " |  \n",
      " |  canonical_variables\n",
      " |      Return a dictionary mapping any variable defined in\n",
      " |      ``self.bound_symbols`` to Symbols that do not clash\n",
      " |      with any free symbols in the expression.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> Lambda(x, 2*x).canonical_variables\n",
      " |      {x: _0}\n",
      " |  \n",
      " |  expr_free_symbols\n",
      " |  \n",
      " |  func\n",
      " |      The top-level function in an expression.\n",
      " |      \n",
      " |      The following should hold for all objects::\n",
      " |      \n",
      " |          >> x == x.func(*x.args)\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> a = 2*x\n",
      " |      >>> a.func\n",
      " |      <class 'sympy.core.mul.Mul'>\n",
      " |      >>> a.args\n",
      " |      (2, x)\n",
      " |      >>> a.func(*a.args)\n",
      " |      2*x\n",
      " |      >>> a == a.func(*a.args)\n",
      " |      True\n",
      " |  \n",
      " |  is_algebraic\n",
      " |  \n",
      " |  is_antihermitian\n",
      " |  \n",
      " |  is_commutative\n",
      " |  \n",
      " |  is_comparable\n",
      " |      Return True if self can be computed to a real number\n",
      " |      (or already is a real number) with precision, else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import exp_polar, pi, I\n",
      " |      >>> (I*exp_polar(I*pi/2)).is_comparable\n",
      " |      True\n",
      " |      >>> (I*exp_polar(I*pi*2)).is_comparable\n",
      " |      False\n",
      " |      \n",
      " |      A False result does not mean that `self` cannot be rewritten\n",
      " |      into a form that would be comparable. For example, the\n",
      " |      difference computed below is zero but without simplification\n",
      " |      it does not evaluate to a zero with precision:\n",
      " |      \n",
      " |      >>> e = 2**pi*(1 + 2**pi)\n",
      " |      >>> dif = e - e.expand()\n",
      " |      >>> dif.is_comparable\n",
      " |      False\n",
      " |      >>> dif.n(2)._prec\n",
      " |      1\n",
      " |  \n",
      " |  is_complex\n",
      " |  \n",
      " |  is_composite\n",
      " |  \n",
      " |  is_even\n",
      " |  \n",
      " |  is_extended_negative\n",
      " |  \n",
      " |  is_extended_nonnegative\n",
      " |  \n",
      " |  is_extended_nonpositive\n",
      " |  \n",
      " |  is_extended_nonzero\n",
      " |  \n",
      " |  is_extended_positive\n",
      " |  \n",
      " |  is_extended_real\n",
      " |  \n",
      " |  is_finite\n",
      " |  \n",
      " |  is_hermitian\n",
      " |  \n",
      " |  is_imaginary\n",
      " |  \n",
      " |  is_infinite\n",
      " |  \n",
      " |  is_integer\n",
      " |  \n",
      " |  is_irrational\n",
      " |  \n",
      " |  is_negative\n",
      " |  \n",
      " |  is_noninteger\n",
      " |  \n",
      " |  is_nonnegative\n",
      " |  \n",
      " |  is_nonpositive\n",
      " |  \n",
      " |  is_nonzero\n",
      " |  \n",
      " |  is_odd\n",
      " |  \n",
      " |  is_polar\n",
      " |  \n",
      " |  is_positive\n",
      " |  \n",
      " |  is_prime\n",
      " |  \n",
      " |  is_rational\n",
      " |  \n",
      " |  is_real\n",
      " |  \n",
      " |  is_transcendental\n",
      " |  \n",
      " |  is_zero\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __annotations__ = {'_args': 'Tuple[Basic, ...]', '_mhash': 'Any', 'kin...\n",
      " |  \n",
      " |  is_Add = False\n",
      " |  \n",
      " |  is_AlgebraicNumber = False\n",
      " |  \n",
      " |  is_Atom = False\n",
      " |  \n",
      " |  is_Boolean = False\n",
      " |  \n",
      " |  is_Derivative = False\n",
      " |  \n",
      " |  is_Dummy = False\n",
      " |  \n",
      " |  is_Equality = False\n",
      " |  \n",
      " |  is_Float = False\n",
      " |  \n",
      " |  is_Function = False\n",
      " |  \n",
      " |  is_Indexed = False\n",
      " |  \n",
      " |  is_Integer = False\n",
      " |  \n",
      " |  is_MatAdd = False\n",
      " |  \n",
      " |  is_MatMul = False\n",
      " |  \n",
      " |  is_Matrix = False\n",
      " |  \n",
      " |  is_Mul = False\n",
      " |  \n",
      " |  is_Not = False\n",
      " |  \n",
      " |  is_Number = False\n",
      " |  \n",
      " |  is_NumberSymbol = False\n",
      " |  \n",
      " |  is_Order = False\n",
      " |  \n",
      " |  is_Piecewise = False\n",
      " |  \n",
      " |  is_Point = False\n",
      " |  \n",
      " |  is_Poly = False\n",
      " |  \n",
      " |  is_Pow = False\n",
      " |  \n",
      " |  is_Rational = False\n",
      " |  \n",
      " |  is_Relational = False\n",
      " |  \n",
      " |  is_Symbol = False\n",
      " |  \n",
      " |  is_Vector = False\n",
      " |  \n",
      " |  is_Wild = False\n",
      " |  \n",
      " |  is_symbol = False\n",
      " |  \n",
      " |  kind = UndefinedKind\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.printing.defaults.Printable:\n",
      " |  \n",
      " |  __repr__ = __str__(self)\n",
      " |  \n",
      " |  __str__(self)\n",
      " |      Return str(self).\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.evalf.EvalfMixin:\n",
      " |  \n",
      " |  evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      " |      Evaluate the given formula to an accuracy of *n* digits.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      subs : dict, optional\n",
      " |          Substitute numerical values for symbols, e.g.\n",
      " |          ``subs={x:3, y:1+pi}``. The substitutions must be given as a\n",
      " |          dictionary.\n",
      " |      \n",
      " |      maxn : int, optional\n",
      " |          Allow a maximum temporary working precision of maxn digits.\n",
      " |      \n",
      " |      chop : bool or number, optional\n",
      " |          Specifies how to replace tiny real or imaginary parts in\n",
      " |          subresults by exact zeros.\n",
      " |      \n",
      " |          When ``True`` the chop value defaults to standard precision.\n",
      " |      \n",
      " |          Otherwise the chop value is used to determine the\n",
      " |          magnitude of \"small\" for purposes of chopping.\n",
      " |      \n",
      " |          >>> from sympy import N\n",
      " |          >>> x = 1e-4\n",
      " |          >>> N(x, chop=True)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-5)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-4)\n",
      " |          0\n",
      " |      \n",
      " |      strict : bool, optional\n",
      " |          Raise ``PrecisionExhausted`` if any subresult fails to\n",
      " |          evaluate to full accuracy, given the available maxprec.\n",
      " |      \n",
      " |      quad : str, optional\n",
      " |          Choose algorithm for numerical quadrature. By default,\n",
      " |          tanh-sinh quadrature is used. For oscillatory\n",
      " |          integrals on an infinite interval, try ``quad='osc'``.\n",
      " |      \n",
      " |      verbose : bool, optional\n",
      " |          Print debug information.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      When Floats are naively substituted into an expression,\n",
      " |      precision errors may adversely affect the result. For example,\n",
      " |      adding 1e16 (a Float) to 1 will truncate to 1e16; if 1e16 is\n",
      " |      then subtracted, the result will be 0.\n",
      " |      That is exactly what happens in the following:\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> values = {x: 1e16, y: 1, z: 1e16}\n",
      " |      >>> (x + y - z).subs(values)\n",
      " |      0\n",
      " |      \n",
      " |      Using the subs argument for evalf is the accurate way to\n",
      " |      evaluate such an expression:\n",
      " |      \n",
      " |      >>> (x + y - z).evalf(subs=values)\n",
      " |      1.00000000000000\n",
      " |  \n",
      " |  n = evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(ConditionSet)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "7ce6ecbe",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class ImageSet in module sympy.sets.fancysets:\n",
      "\n",
      "class ImageSet(sympy.sets.sets.Set)\n",
      " |  ImageSet(flambda, *sets)\n",
      " |  \n",
      " |  Image of a set under a mathematical function. The transformation\n",
      " |  must be given as a Lambda function which has as many arguments\n",
      " |  as the elements of the set upon which it operates, e.g. 1 argument\n",
      " |  when acting on the set of integers or 2 arguments when acting on\n",
      " |  a complex region.\n",
      " |  \n",
      " |  This function is not normally called directly, but is called\n",
      " |  from ``imageset``.\n",
      " |  \n",
      " |  \n",
      " |  Examples\n",
      " |  ========\n",
      " |  \n",
      " |  >>> from sympy import Symbol, S, pi, Dummy, Lambda\n",
      " |  >>> from sympy import FiniteSet, ImageSet, Interval\n",
      " |  \n",
      " |  >>> x = Symbol('x')\n",
      " |  >>> N = S.Naturals\n",
      " |  >>> squares = ImageSet(Lambda(x, x**2), N) # {x**2 for x in N}\n",
      " |  >>> 4 in squares\n",
      " |  True\n",
      " |  >>> 5 in squares\n",
      " |  False\n",
      " |  \n",
      " |  >>> FiniteSet(0, 1, 2, 3, 4, 5, 6, 7, 9, 10).intersect(squares)\n",
      " |  {1, 4, 9}\n",
      " |  \n",
      " |  >>> square_iterable = iter(squares)\n",
      " |  >>> for i in range(4):\n",
      " |  ...     next(square_iterable)\n",
      " |  1\n",
      " |  4\n",
      " |  9\n",
      " |  16\n",
      " |  \n",
      " |  If you want to get value for `x` = 2, 1/2 etc. (Please check whether the\n",
      " |  `x` value is in ``base_set`` or not before passing it as args)\n",
      " |  \n",
      " |  >>> squares.lamda(2)\n",
      " |  4\n",
      " |  >>> squares.lamda(S(1)/2)\n",
      " |  1/4\n",
      " |  \n",
      " |  >>> n = Dummy('n')\n",
      " |  >>> solutions = ImageSet(Lambda(n, n*pi), S.Integers) # solutions of sin(x) = 0\n",
      " |  >>> dom = Interval(-1, 1)\n",
      " |  >>> dom.intersect(solutions)\n",
      " |  {0}\n",
      " |  \n",
      " |  See Also\n",
      " |  ========\n",
      " |  \n",
      " |  sympy.sets.sets.imageset\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      ImageSet\n",
      " |      sympy.sets.sets.Set\n",
      " |      sympy.core.basic.Basic\n",
      " |      sympy.printing.defaults.Printable\n",
      " |      sympy.core.evalf.EvalfMixin\n",
      " |      builtins.object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  __iter__(self)\n",
      " |  \n",
      " |  doit(self, **kwargs)\n",
      " |      Evaluate objects that are not evaluated by default like limits,\n",
      " |      integrals, sums and products. All objects of this kind will be\n",
      " |      evaluated recursively, unless some species were excluded via 'hints'\n",
      " |      or unless the 'deep' hint was set to 'False'.\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> 2*Integral(x, x)\n",
      " |      2*Integral(x, x)\n",
      " |      \n",
      " |      >>> (2*Integral(x, x)).doit()\n",
      " |      x**2\n",
      " |      \n",
      " |      >>> (2*Integral(x, x)).doit(deep=False)\n",
      " |      2*Integral(x, x)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  __new__(cls, flambda, *sets)\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties defined here:\n",
      " |  \n",
      " |  __sympy__\n",
      " |  \n",
      " |  base_pset\n",
      " |  \n",
      " |  base_set\n",
      " |  \n",
      " |  base_sets\n",
      " |  \n",
      " |  is_iterable\n",
      " |  \n",
      " |  lamda\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes defined here:\n",
      " |  \n",
      " |  default_assumptions = {}\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.sets.sets.Set:\n",
      " |  \n",
      " |  __add__(self, other)\n",
      " |  \n",
      " |  __and__(self, other)\n",
      " |  \n",
      " |  __contains__(self, other)\n",
      " |  \n",
      " |  __mul__(self, other)\n",
      " |  \n",
      " |  __or__(self, other)\n",
      " |  \n",
      " |  __pow__(self, exp)\n",
      " |  \n",
      " |  __sub__(self, other)\n",
      " |  \n",
      " |  __xor__(self, other)\n",
      " |  \n",
      " |  complement(self, universe)\n",
      " |      The complement of 'self' w.r.t the given universe.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, S\n",
      " |      >>> Interval(0, 1).complement(S.Reals)\n",
      " |      Union(Interval.open(-oo, 0), Interval.open(1, oo))\n",
      " |      \n",
      " |      >>> Interval(0, 1).complement(S.UniversalSet)\n",
      " |      Complement(UniversalSet, Interval(0, 1))\n",
      " |  \n",
      " |  contains(self, other)\n",
      " |      Returns a SymPy value indicating whether ``other`` is contained\n",
      " |      in ``self``: ``true`` if it is, ``false`` if it isn't, else\n",
      " |      an unevaluated ``Contains`` expression (or, as in the case of\n",
      " |      ConditionSet and a union of FiniteSet/Intervals, an expression\n",
      " |      indicating the conditions for containment).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, S\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> Interval(0, 1).contains(0.5)\n",
      " |      True\n",
      " |      \n",
      " |      As a shortcut it is possible to use the ``in`` operator, but that\n",
      " |      will raise an error unless an affirmative true or false is not\n",
      " |      obtained.\n",
      " |      \n",
      " |      >>> Interval(0, 1).contains(x)\n",
      " |      (0 <= x) & (x <= 1)\n",
      " |      >>> x in Interval(0, 1)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      TypeError: did not evaluate to a bool: None\n",
      " |      \n",
      " |      The result of 'in' is a bool, not a SymPy value\n",
      " |      \n",
      " |      >>> 1 in Interval(0, 2)\n",
      " |      True\n",
      " |      >>> _ is S.true\n",
      " |      False\n",
      " |  \n",
      " |  intersect(self, other)\n",
      " |      Returns the intersection of 'self' and 'other'.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      \n",
      " |      >>> Interval(1, 3).intersect(Interval(1, 2))\n",
      " |      Interval(1, 2)\n",
      " |      \n",
      " |      >>> from sympy import imageset, Lambda, symbols, S\n",
      " |      >>> n, m = symbols('n m')\n",
      " |      >>> a = imageset(Lambda(n, 2*n), S.Integers)\n",
      " |      >>> a.intersect(imageset(Lambda(m, 2*m + 1), S.Integers))\n",
      " |      EmptySet\n",
      " |  \n",
      " |  intersection(self, other)\n",
      " |      Alias for :meth:`intersect()`\n",
      " |  \n",
      " |  is_disjoint(self, other)\n",
      " |      Returns True if ``self`` and ``other`` are disjoint.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 2).is_disjoint(Interval(1, 2))\n",
      " |      False\n",
      " |      >>> Interval(0, 2).is_disjoint(Interval(3, 4))\n",
      " |      True\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Disjoint_sets\n",
      " |  \n",
      " |  is_proper_subset(self, other)\n",
      " |      Returns True if ``self`` is a proper subset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 0.5).is_proper_subset(Interval(0, 1))\n",
      " |      True\n",
      " |      >>> Interval(0, 1).is_proper_subset(Interval(0, 1))\n",
      " |      False\n",
      " |  \n",
      " |  is_proper_superset(self, other)\n",
      " |      Returns True if ``self`` is a proper superset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).is_proper_superset(Interval(0, 0.5))\n",
      " |      True\n",
      " |      >>> Interval(0, 1).is_proper_superset(Interval(0, 1))\n",
      " |      False\n",
      " |  \n",
      " |  is_subset(self, other)\n",
      " |      Returns True if ``self`` is a subset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 0.5).is_subset(Interval(0, 1))\n",
      " |      True\n",
      " |      >>> Interval(0, 1).is_subset(Interval(0, 1, left_open=True))\n",
      " |      False\n",
      " |  \n",
      " |  is_superset(self, other)\n",
      " |      Returns True if ``self`` is a superset of ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 0.5).is_superset(Interval(0, 1))\n",
      " |      False\n",
      " |      >>> Interval(0, 1).is_superset(Interval(0, 1, left_open=True))\n",
      " |      True\n",
      " |  \n",
      " |  isdisjoint(self, other)\n",
      " |      Alias for :meth:`is_disjoint()`\n",
      " |  \n",
      " |  issubset(self, other)\n",
      " |      Alias for :meth:`is_subset()`\n",
      " |  \n",
      " |  issuperset(self, other)\n",
      " |      Alias for :meth:`is_superset()`\n",
      " |  \n",
      " |  powerset(self)\n",
      " |      Find the Power set of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import EmptySet, FiniteSet, Interval\n",
      " |      \n",
      " |      A power set of an empty set:\n",
      " |      \n",
      " |      >>> A = EmptySet\n",
      " |      >>> A.powerset()\n",
      " |      {EmptySet}\n",
      " |      \n",
      " |      A power set of a finite set:\n",
      " |      \n",
      " |      >>> A = FiniteSet(1, 2)\n",
      " |      >>> a, b, c = FiniteSet(1), FiniteSet(2), FiniteSet(1, 2)\n",
      " |      >>> A.powerset() == FiniteSet(a, b, c, EmptySet)\n",
      " |      True\n",
      " |      \n",
      " |      A power set of an interval:\n",
      " |      \n",
      " |      >>> Interval(1, 2).powerset()\n",
      " |      PowerSet(Interval(1, 2))\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Power_set\n",
      " |  \n",
      " |  symmetric_difference(self, other)\n",
      " |      Returns symmetric difference of ``self`` and ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, S\n",
      " |      >>> Interval(1, 3).symmetric_difference(S.Reals)\n",
      " |      Union(Interval.open(-oo, 1), Interval.open(3, oo))\n",
      " |      >>> Interval(1, 10).symmetric_difference(S.Reals)\n",
      " |      Union(Interval.open(-oo, 1), Interval.open(10, oo))\n",
      " |      \n",
      " |      >>> from sympy import S, EmptySet\n",
      " |      >>> S.Reals.symmetric_difference(EmptySet)\n",
      " |      Reals\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      .. [1] https://en.wikipedia.org/wiki/Symmetric_difference\n",
      " |  \n",
      " |  union(self, other)\n",
      " |      Returns the union of ``self`` and ``other``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      As a shortcut it is possible to use the ``+`` operator:\n",
      " |      \n",
      " |      >>> from sympy import Interval, FiniteSet\n",
      " |      >>> Interval(0, 1).union(Interval(2, 3))\n",
      " |      Union(Interval(0, 1), Interval(2, 3))\n",
      " |      >>> Interval(0, 1) + Interval(2, 3)\n",
      " |      Union(Interval(0, 1), Interval(2, 3))\n",
      " |      >>> Interval(1, 2, True, True) + FiniteSet(2, 3)\n",
      " |      Union({3}, Interval.Lopen(1, 2))\n",
      " |      \n",
      " |      Similarly it is possible to use the ``-`` operator for set differences:\n",
      " |      \n",
      " |      >>> Interval(0, 2) - Interval(0, 1)\n",
      " |      Interval.Lopen(1, 2)\n",
      " |      >>> Interval(1, 3) - FiniteSet(2)\n",
      " |      Union(Interval.Ropen(1, 2), Interval.Lopen(2, 3))\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.sets.sets.Set:\n",
      " |  \n",
      " |  boundary\n",
      " |      The boundary or frontier of a set.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A point x is on the boundary of a set S if\n",
      " |      \n",
      " |      1.  x is in the closure of S.\n",
      " |          I.e. Every neighborhood of x contains a point in S.\n",
      " |      2.  x is not in the interior of S.\n",
      " |          I.e. There does not exist an open set centered on x contained\n",
      " |          entirely within S.\n",
      " |      \n",
      " |      There are the points on the outer rim of S.  If S is open then these\n",
      " |      points need not actually be contained within S.\n",
      " |      \n",
      " |      For example, the boundary of an interval is its start and end points.\n",
      " |      This is true regardless of whether or not the interval is open.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).boundary\n",
      " |      {0, 1}\n",
      " |      >>> Interval(0, 1, True, False).boundary\n",
      " |      {0, 1}\n",
      " |  \n",
      " |  closure\n",
      " |      Property method which returns the closure of a set.\n",
      " |      The closure is defined as the union of the set itself and its\n",
      " |      boundary.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import S, Interval\n",
      " |      >>> S.Reals.closure\n",
      " |      Reals\n",
      " |      >>> Interval(0, 1).closure\n",
      " |      Interval(0, 1)\n",
      " |  \n",
      " |  inf\n",
      " |      The infimum of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, Union\n",
      " |      >>> Interval(0, 1).inf\n",
      " |      0\n",
      " |      >>> Union(Interval(0, 1), Interval(2, 3)).inf\n",
      " |      0\n",
      " |  \n",
      " |  interior\n",
      " |      Property method which returns the interior of a set.\n",
      " |      The interior of a set S consists all points of S that do not\n",
      " |      belong to the boundary of S.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).interior\n",
      " |      Interval.open(0, 1)\n",
      " |      >>> Interval(0, 1).boundary.interior\n",
      " |      EmptySet\n",
      " |  \n",
      " |  is_EmptySet\n",
      " |  \n",
      " |  is_closed\n",
      " |      A property method to check whether a set is closed.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A set is closed if its complement is an open set. The closedness of a\n",
      " |      subset of the reals is determined with respect to R and its standard\n",
      " |      topology.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import Interval\n",
      " |      >>> Interval(0, 1).is_closed\n",
      " |      True\n",
      " |  \n",
      " |  is_open\n",
      " |      Property method to check whether a set is open.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      A set is open if and only if it has an empty intersection with its\n",
      " |      boundary. In particular, a subset A of the reals is open if and only\n",
      " |      if each one of its points is contained in an open interval that is a\n",
      " |      subset of A.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      >>> from sympy import S\n",
      " |      >>> S.Reals.is_open\n",
      " |      True\n",
      " |      >>> S.Rationals.is_open\n",
      " |      False\n",
      " |  \n",
      " |  measure\n",
      " |      The (Lebesgue) measure of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, Union\n",
      " |      >>> Interval(0, 1).measure\n",
      " |      1\n",
      " |      >>> Union(Interval(0, 1), Interval(2, 3)).measure\n",
      " |      2\n",
      " |  \n",
      " |  sup\n",
      " |      The supremum of ``self``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Interval, Union\n",
      " |      >>> Interval(0, 1).sup\n",
      " |      1\n",
      " |      >>> Union(Interval(0, 1), Interval(2, 3)).sup\n",
      " |      3\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from sympy.sets.sets.Set:\n",
      " |  \n",
      " |  __dict__\n",
      " |      dictionary for instance variables (if defined)\n",
      " |  \n",
      " |  __weakref__\n",
      " |      list of weak references to the object (if defined)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.sets.sets.Set:\n",
      " |  \n",
      " |  is_Complement = None\n",
      " |  \n",
      " |  is_ComplexRegion = False\n",
      " |  \n",
      " |  is_FiniteSet = False\n",
      " |  \n",
      " |  is_Intersection = None\n",
      " |  \n",
      " |  is_Interval = False\n",
      " |  \n",
      " |  is_ProductSet = False\n",
      " |  \n",
      " |  is_Union = False\n",
      " |  \n",
      " |  is_UniversalSet = None\n",
      " |  \n",
      " |  is_empty = None\n",
      " |  \n",
      " |  is_finite_set = None\n",
      " |  \n",
      " |  is_interval = False\n",
      " |  \n",
      " |  is_number = False\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __eq__(self, other)\n",
      " |      Return a boolean indicating whether a == b on the basis of\n",
      " |      their symbolic trees.\n",
      " |      \n",
      " |      This is the same as a.compare(b) == 0 but faster.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      If a class that overrides __eq__() needs to retain the\n",
      " |      implementation of __hash__() from a parent class, the\n",
      " |      interpreter must be told this explicitly by setting\n",
      " |      __hash__ : Callable[[object], int] = <ParentClass>.__hash__.\n",
      " |      Otherwise the inheritance of __hash__() will be blocked,\n",
      " |      just as if __hash__ had been explicitly set to None.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      from http://docs.python.org/dev/reference/datamodel.html#object.__hash__\n",
      " |  \n",
      " |  __getnewargs__(self)\n",
      " |  \n",
      " |  __getstate__(self)\n",
      " |  \n",
      " |  __hash__(self) -> int\n",
      " |      Return hash(self).\n",
      " |  \n",
      " |  __ne__(self, other)\n",
      " |      ``a != b``  -> Compare two symbolic trees and see whether they are different\n",
      " |      \n",
      " |      this is the same as:\n",
      " |      \n",
      " |      ``a.compare(b) != 0``\n",
      " |      \n",
      " |      but faster\n",
      " |  \n",
      " |  __reduce_ex__(self, protocol)\n",
      " |      Helper for pickle.\n",
      " |  \n",
      " |  __setstate__(self, state)\n",
      " |  \n",
      " |  as_content_primitive(self, radical=False, clear=True)\n",
      " |      A stub to allow Basic args (like Tuple) to be skipped when computing\n",
      " |      the content and primitive components of an expression.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.core.expr.Expr.as_content_primitive\n",
      " |  \n",
      " |  as_dummy(self)\n",
      " |      Return the expression with any objects having structurally\n",
      " |      bound symbols replaced with unique, canonical symbols within\n",
      " |      the object in which they appear and having only the default\n",
      " |      assumption for commutativity being True. When applied to a\n",
      " |      symbol a new symbol having only the same commutativity will be\n",
      " |      returned.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> r = Symbol('r', real=True)\n",
      " |      >>> Integral(r, (r, x)).as_dummy()\n",
      " |      Integral(_0, (_0, x))\n",
      " |      >>> _.variables[0].is_real is None\n",
      " |      True\n",
      " |      >>> r.as_dummy()\n",
      " |      _r\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Any object that has structurally bound variables should have\n",
      " |      a property, `bound_symbols` that returns those symbols\n",
      " |      appearing in the object.\n",
      " |  \n",
      " |  atoms(self, *types)\n",
      " |      Returns the atoms that form the current object.\n",
      " |      \n",
      " |      By default, only objects that are truly atomic and cannot\n",
      " |      be divided into smaller pieces are returned: symbols, numbers,\n",
      " |      and number symbols like I and pi. It is possible to request\n",
      " |      atoms of any type, however, as demonstrated below.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import I, pi, sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms()\n",
      " |      {1, 2, I, pi, x, y}\n",
      " |      \n",
      " |      If one or more types are given, the results will contain only\n",
      " |      those types of atoms.\n",
      " |      \n",
      " |      >>> from sympy import Number, NumberSymbol, Symbol\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Symbol)\n",
      " |      {x, y}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number)\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol)\n",
      " |      {1, 2, pi}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol, I)\n",
      " |      {1, 2, I, pi}\n",
      " |      \n",
      " |      Note that I (imaginary unit) and zoo (complex infinity) are special\n",
      " |      types of number symbols and are not part of the NumberSymbol class.\n",
      " |      \n",
      " |      The type can be given implicitly, too:\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(x) # x is a Symbol\n",
      " |      {x, y}\n",
      " |      \n",
      " |      Be careful to check your assumptions when using the implicit option\n",
      " |      since ``S(1).is_Integer = True`` but ``type(S(1))`` is ``One``, a special type\n",
      " |      of SymPy atom, while ``type(S(2))`` is type ``Integer`` and will find all\n",
      " |      integers in an expression:\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(1))\n",
      " |      {1}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(2))\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      Finally, arguments to atoms() can select more than atomic atoms: any\n",
      " |      SymPy type (loaded in core/__init__.py) can be listed as an argument\n",
      " |      and those types of \"atoms\" as found in scanning the arguments of the\n",
      " |      expression recursively:\n",
      " |      \n",
      " |      >>> from sympy import Function, Mul\n",
      " |      >>> from sympy.core.function import AppliedUndef\n",
      " |      >>> f = Function('f')\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(Function)\n",
      " |      {f(x), sin(y + I*pi)}\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(AppliedUndef)\n",
      " |      {f(x)}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Mul)\n",
      " |      {I*pi, 2*sin(y + I*pi)}\n",
      " |  \n",
      " |  compare(self, other)\n",
      " |      Return -1, 0, 1 if the object is smaller, equal, or greater than other.\n",
      " |      \n",
      " |      Not in the mathematical sense. If the object is of a different type\n",
      " |      from the \"other\" then their classes are ordered according to\n",
      " |      the sorted_classes list.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> x.compare(y)\n",
      " |      -1\n",
      " |      >>> x.compare(x)\n",
      " |      0\n",
      " |      >>> y.compare(x)\n",
      " |      1\n",
      " |  \n",
      " |  copy(self)\n",
      " |  \n",
      " |  could_extract_minus_sign(self)\n",
      " |  \n",
      " |  count(self, query)\n",
      " |      Count the number of matching subexpressions.\n",
      " |  \n",
      " |  count_ops(self, visual=None)\n",
      " |      wrapper for count_ops that returns the operation count.\n",
      " |  \n",
      " |  dummy_eq(self, other, symbol=None)\n",
      " |      Compare two expressions and handle dummy symbols.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Dummy\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> u = Dummy('u')\n",
      " |      \n",
      " |      >>> (u**2 + 1).dummy_eq(x**2 + 1)\n",
      " |      True\n",
      " |      >>> (u**2 + 1) == (x**2 + 1)\n",
      " |      False\n",
      " |      \n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, x)\n",
      " |      True\n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, y)\n",
      " |      False\n",
      " |  \n",
      " |  find(self, query, group=False)\n",
      " |      Find all subexpressions matching a query.\n",
      " |  \n",
      " |  has(self, *patterns)\n",
      " |      Test whether any subexpression matches any of the patterns.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x**2 + sin(x*y)).has(z)\n",
      " |      False\n",
      " |      >>> (x**2 + sin(x*y)).has(x, y, z)\n",
      " |      True\n",
      " |      >>> x.has(x)\n",
      " |      True\n",
      " |      \n",
      " |      Note ``has`` is a structural algorithm with no knowledge of\n",
      " |      mathematics. Consider the following half-open interval:\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> i = Interval.Lopen(0, 5); i\n",
      " |      Interval.Lopen(0, 5)\n",
      " |      >>> i.args\n",
      " |      (0, 5, True, False)\n",
      " |      >>> i.has(4)  # there is no \"4\" in the arguments\n",
      " |      False\n",
      " |      >>> i.has(0)  # there *is* a \"0\" in the arguments\n",
      " |      True\n",
      " |      \n",
      " |      Instead, use ``contains`` to determine whether a number is in the\n",
      " |      interval or not:\n",
      " |      \n",
      " |      >>> i.contains(4)\n",
      " |      True\n",
      " |      >>> i.contains(0)\n",
      " |      False\n",
      " |      \n",
      " |      \n",
      " |      Note that ``expr.has(*patterns)`` is exactly equivalent to\n",
      " |      ``any(expr.has(p) for p in patterns)``. In particular, ``False`` is\n",
      " |      returned when the list of patterns is empty.\n",
      " |      \n",
      " |      >>> x.has()\n",
      " |      False\n",
      " |  \n",
      " |  has_free(self, *patterns)\n",
      " |      return True if self has object(s) ``x`` as a free expression\n",
      " |      else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Function\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = Function('f')\n",
      " |      >>> g = Function('g')\n",
      " |      >>> expr = Integral(f(x), (f(x), 1, g(y)))\n",
      " |      >>> expr.free_symbols\n",
      " |      {y}\n",
      " |      >>> expr.has_free(g(y))\n",
      " |      True\n",
      " |      >>> expr.has_free(*(x, f(x)))\n",
      " |      False\n",
      " |      \n",
      " |      This works for subexpressions and types, too:\n",
      " |      \n",
      " |      >>> expr.has_free(g)\n",
      " |      True\n",
      " |      >>> (x + y + 1).has_free(y + 1)\n",
      " |      True\n",
      " |  \n",
      " |  is_hypergeometric(self, k)\n",
      " |  \n",
      " |  match(self, pattern, old=False)\n",
      " |      Pattern matching.\n",
      " |      \n",
      " |      Wild symbols match all.\n",
      " |      \n",
      " |      Return ``None`` when expression (self) does not match\n",
      " |      with pattern. Otherwise return a dictionary such that::\n",
      " |      \n",
      " |        pattern.xreplace(self.match(pattern)) == self\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Wild, Sum\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> p = Wild(\"p\")\n",
      " |      >>> q = Wild(\"q\")\n",
      " |      >>> r = Wild(\"r\")\n",
      " |      >>> e = (x+y)**(x+y)\n",
      " |      >>> e.match(p**p)\n",
      " |      {p_: x + y}\n",
      " |      >>> e.match(p**q)\n",
      " |      {p_: x + y, q_: x + y}\n",
      " |      >>> e = (2*x)**2\n",
      " |      >>> e.match(p*q**r)\n",
      " |      {p_: 4, q_: x, r_: 2}\n",
      " |      >>> (p*q**r).xreplace(e.match(p*q**r))\n",
      " |      4*x**2\n",
      " |      \n",
      " |      Structurally bound symbols are ignored during matching:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(y, (y, 1, p)))\n",
      " |      {p_: 2}\n",
      " |      \n",
      " |      But they can be identified if desired:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(q, (q, 1, p)))\n",
      " |      {p_: 2, q_: x}\n",
      " |      \n",
      " |      The ``old`` flag will give the old-style pattern matching where\n",
      " |      expressions and patterns are essentially solved to give the\n",
      " |      match. Both of the following give None unless ``old=True``:\n",
      " |      \n",
      " |      >>> (x - 2).match(p - x, old=True)\n",
      " |      {p_: 2*x - 2}\n",
      " |      >>> (2/x).match(p*x, old=True)\n",
      " |      {p_: 2/x**2}\n",
      " |  \n",
      " |  matches(self, expr, repl_dict=None, old=False)\n",
      " |      Helper method for match() that looks for a match between Wild symbols\n",
      " |      in self and expressions in expr.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, Wild, Basic\n",
      " |      >>> a, b, c = symbols('a b c')\n",
      " |      >>> x = Wild('x')\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b, c)) is None\n",
      " |      True\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b + c, b + c))\n",
      " |      {x_: b + c}\n",
      " |  \n",
      " |  rcall(self, *args)\n",
      " |      Apply on the argument recursively through the expression tree.\n",
      " |      \n",
      " |      This method is used to simulate a common abuse of notation for\n",
      " |      operators. For instance, in SymPy the following will not work:\n",
      " |      \n",
      " |      ``(x+Lambda(y, 2*y))(z) == x+2*z``,\n",
      " |      \n",
      " |      however, you can use:\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x + Lambda(y, 2*y)).rcall(z)\n",
      " |      x + 2*z\n",
      " |  \n",
      " |  refine(self, assumption=True)\n",
      " |      See the refine function in sympy.assumptions\n",
      " |  \n",
      " |  replace(self, query, value, map=False, simultaneous=True, exact=None)\n",
      " |      Replace matching subexpressions of ``self`` with ``value``.\n",
      " |      \n",
      " |      If ``map = True`` then also return the mapping {old: new} where ``old``\n",
      " |      was a sub-expression found with query and ``new`` is the replacement\n",
      " |      value for it. If the expression itself doesn't match the query, then\n",
      " |      the returned value will be ``self.xreplace(map)`` otherwise it should\n",
      " |      be ``self.subs(ordered(map.items()))``.\n",
      " |      \n",
      " |      Traverses an expression tree and performs replacement of matching\n",
      " |      subexpressions from the bottom to the top of the tree. The default\n",
      " |      approach is to do the replacement in a simultaneous fashion so\n",
      " |      changes made are targeted only once. If this is not desired or causes\n",
      " |      problems, ``simultaneous`` can be set to False.\n",
      " |      \n",
      " |      In addition, if an expression containing more than one Wild symbol\n",
      " |      is being used to match subexpressions and the ``exact`` flag is None\n",
      " |      it will be set to True so the match will only succeed if all non-zero\n",
      " |      values are received for each Wild that appears in the match pattern.\n",
      " |      Setting this to False accepts a match of 0; while setting it True\n",
      " |      accepts all matches that have a 0 in them. See example below for\n",
      " |      cautions.\n",
      " |      \n",
      " |      The list of possible combinations of queries and replacement values\n",
      " |      is listed below:\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      Initial setup\n",
      " |      \n",
      " |      >>> from sympy import log, sin, cos, tan, Wild, Mul, Add\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = log(sin(x)) + tan(sin(x**2))\n",
      " |      \n",
      " |      1.1. type -> type\n",
      " |          obj.replace(type, newtype)\n",
      " |      \n",
      " |          When object of type ``type`` is found, replace it with the\n",
      " |          result of passing its argument(s) to ``newtype``.\n",
      " |      \n",
      " |          >>> f.replace(sin, cos)\n",
      " |          log(cos(x)) + tan(cos(x**2))\n",
      " |          >>> sin(x).replace(sin, cos, map=True)\n",
      " |          (cos(x), {sin(x): cos(x)})\n",
      " |          >>> (x*y).replace(Mul, Add)\n",
      " |          x + y\n",
      " |      \n",
      " |      1.2. type -> func\n",
      " |          obj.replace(type, func)\n",
      " |      \n",
      " |          When object of type ``type`` is found, apply ``func`` to its\n",
      " |          argument(s). ``func`` must be written to handle the number\n",
      " |          of arguments of ``type``.\n",
      " |      \n",
      " |          >>> f.replace(sin, lambda arg: sin(2*arg))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |          >>> (x*y).replace(Mul, lambda *args: sin(2*Mul(*args)))\n",
      " |          sin(2*x*y)\n",
      " |      \n",
      " |      2.1. pattern -> expr\n",
      " |          obj.replace(pattern(wild), expr(wild))\n",
      " |      \n",
      " |          Replace subexpressions matching ``pattern`` with the expression\n",
      " |          written in terms of the Wild symbols in ``pattern``.\n",
      " |      \n",
      " |          >>> a, b = map(Wild, 'ab')\n",
      " |          >>> f.replace(sin(a), tan(a))\n",
      " |          log(tan(x)) + tan(tan(x**2))\n",
      " |          >>> f.replace(sin(a), tan(a/2))\n",
      " |          log(tan(x/2)) + tan(tan(x**2/2))\n",
      " |          >>> f.replace(sin(a), a)\n",
      " |          log(x) + tan(x**2)\n",
      " |          >>> (x*y).replace(a*x, a)\n",
      " |          y\n",
      " |      \n",
      " |          Matching is exact by default when more than one Wild symbol\n",
      " |          is used: matching fails unless the match gives non-zero\n",
      " |          values for all Wild symbols:\n",
      " |      \n",
      " |          >>> (2*x + y).replace(a*x + b, b - a)\n",
      " |          y - 2\n",
      " |          >>> (2*x).replace(a*x + b, b - a)\n",
      " |          2*x\n",
      " |      \n",
      " |          When set to False, the results may be non-intuitive:\n",
      " |      \n",
      " |          >>> (2*x).replace(a*x + b, b - a, exact=False)\n",
      " |          2/x\n",
      " |      \n",
      " |      2.2. pattern -> func\n",
      " |          obj.replace(pattern(wild), lambda wild: expr(wild))\n",
      " |      \n",
      " |          All behavior is the same as in 2.1 but now a function in terms of\n",
      " |          pattern variables is used rather than an expression:\n",
      " |      \n",
      " |          >>> f.replace(sin(a), lambda a: sin(2*a))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |      \n",
      " |      3.1. func -> func\n",
      " |          obj.replace(filter, func)\n",
      " |      \n",
      " |          Replace subexpression ``e`` with ``func(e)`` if ``filter(e)``\n",
      " |          is True.\n",
      " |      \n",
      " |          >>> g = 2*sin(x**3)\n",
      " |          >>> g.replace(lambda expr: expr.is_Number, lambda expr: expr**2)\n",
      " |          4*sin(x**9)\n",
      " |      \n",
      " |      The expression itself is also targeted by the query but is done in\n",
      " |      such a fashion that changes are not made twice.\n",
      " |      \n",
      " |          >>> e = x*(x*y + 1)\n",
      " |          >>> e.replace(lambda x: x.is_Mul, lambda x: 2*x)\n",
      " |          2*x*(2*x*y + 1)\n",
      " |      \n",
      " |      When matching a single symbol, `exact` will default to True, but\n",
      " |      this may or may not be the behavior that is desired:\n",
      " |      \n",
      " |      Here, we want `exact=False`:\n",
      " |      \n",
      " |      >>> from sympy import Function\n",
      " |      >>> f = Function('f')\n",
      " |      >>> e = f(1) + f(0)\n",
      " |      >>> q = f(a), lambda a: f(a + 1)\n",
      " |      >>> e.replace(*q, exact=False)\n",
      " |      f(1) + f(2)\n",
      " |      >>> e.replace(*q, exact=True)\n",
      " |      f(0) + f(2)\n",
      " |      \n",
      " |      But here, the nature of matching makes selecting\n",
      " |      the right setting tricky:\n",
      " |      \n",
      " |      >>> e = x**(1 + y)\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(-x - y + 1)\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(1 - y)\n",
      " |      \n",
      " |      It is probably better to use a different form of the query\n",
      " |      that describes the target expression more precisely:\n",
      " |      \n",
      " |      >>> (1 + x**(1 + y)).replace(\n",
      " |      ... lambda x: x.is_Pow and x.exp.is_Add and x.exp.args[0] == 1,\n",
      " |      ... lambda x: x.base**(1 - (x.exp - 1)))\n",
      " |      ...\n",
      " |      x**(1 - y) + 1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      subs: substitution of subexpressions as defined by the objects\n",
      " |            themselves.\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |  \n",
      " |  rewrite(self, *args, deep=True, **hints)\n",
      " |      Rewrite *self* using a defined rule.\n",
      " |      \n",
      " |      Rewriting transforms an expression to another, which is mathematically\n",
      " |      equivalent but structurally different. For example you can rewrite\n",
      " |      trigonometric functions as complex exponentials or combinatorial\n",
      " |      functions as gamma function.\n",
      " |      \n",
      " |      This method takes a *pattern* and a *rule* as positional arguments.\n",
      " |      *pattern* is optional parameter which defines the types of expressions\n",
      " |      that will be transformed. If it is not passed, all possible expressions\n",
      " |      will be rewritten. *rule* defines how the expression will be rewritten.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      args : *rule*, or *pattern* and *rule*.\n",
      " |          - *pattern* is a type or an iterable of types.\n",
      " |          - *rule* can be any object.\n",
      " |      \n",
      " |      deep : bool, optional.\n",
      " |          If ``True``, subexpressions are recursively transformed. Default is\n",
      " |          ``True``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      If *pattern* is unspecified, all possible expressions are transformed.\n",
      " |      \n",
      " |      >>> from sympy import cos, sin, exp, I\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> expr = cos(x) + I*sin(x)\n",
      " |      >>> expr.rewrite(exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Pattern can be a type or an iterable of types.\n",
      " |      \n",
      " |      >>> expr.rewrite(sin, exp)\n",
      " |      exp(I*x)/2 + cos(x) - exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos,], exp)\n",
      " |      exp(I*x)/2 + I*sin(x) + exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos, sin], exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Rewriting behavior can be implemented by defining ``_eval_rewrite()``\n",
      " |      method.\n",
      " |      \n",
      " |      >>> from sympy import Expr, sqrt, pi\n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite(self, rule, args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         if rule == cos:\n",
      " |      ...             return cos(pi/2 - x, evaluate=False)\n",
      " |      ...         if rule == sqrt:\n",
      " |      ...             return sqrt(1 - cos(x)**2)\n",
      " |      >>> MySin(MySin(x)).rewrite(cos)\n",
      " |      cos(-cos(-x + pi/2) + pi/2)\n",
      " |      >>> MySin(x).rewrite(sqrt)\n",
      " |      sqrt(1 - cos(x)**2)\n",
      " |      \n",
      " |      Defining ``_eval_rewrite_as_[...]()`` method is supported for backwards\n",
      " |      compatibility reason. This may be removed in the future and using it is\n",
      " |      discouraged.\n",
      " |      \n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite_as_cos(self, *args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         return cos(pi/2 - x, evaluate=False)\n",
      " |      >>> MySin(x).rewrite(cos)\n",
      " |      cos(-x + pi/2)\n",
      " |  \n",
      " |  simplify(self, **kwargs)\n",
      " |      See the simplify function in sympy.simplify\n",
      " |  \n",
      " |  sort_key(self, order=None)\n",
      " |      Return a sort key.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import S, I\n",
      " |      \n",
      " |      >>> sorted([S(1)/2, I, -I], key=lambda x: x.sort_key())\n",
      " |      [1/2, -I, I]\n",
      " |      \n",
      " |      >>> S(\"[x, 1/x, 1/x**2, x**2, x**(1/2), x**(1/4), x**(3/2)]\")\n",
      " |      [x, 1/x, x**(-2), x**2, sqrt(x), x**(1/4), x**(3/2)]\n",
      " |      >>> sorted(_, key=lambda x: x.sort_key())\n",
      " |      [x**(-2), 1/x, x**(1/4), sqrt(x), x, x**(3/2), x**2]\n",
      " |  \n",
      " |  subs(self, *args, **kwargs)\n",
      " |      Substitutes old for new in an expression after sympifying args.\n",
      " |      \n",
      " |      `args` is either:\n",
      " |        - two arguments, e.g. foo.subs(old, new)\n",
      " |        - one iterable argument, e.g. foo.subs(iterable). The iterable may be\n",
      " |           o an iterable container with (old, new) pairs. In this case the\n",
      " |             replacements are processed in the order given with successive\n",
      " |             patterns possibly affecting replacements already made.\n",
      " |           o a dict or set whose key/value items correspond to old/new pairs.\n",
      " |             In this case the old/new pairs will be sorted by op count and in\n",
      " |             case of a tie, by number of args and the default_sort_key. The\n",
      " |             resulting sorted list is then processed as an iterable container\n",
      " |             (see previous).\n",
      " |      \n",
      " |      If the keyword ``simultaneous`` is True, the subexpressions will not be\n",
      " |      evaluated until all the substitutions have been made.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import pi, exp, limit, oo\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x*y).subs(x, pi)\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).subs({x:pi, y:2})\n",
      " |      1 + 2*pi\n",
      " |      >>> (1 + x*y).subs([(x, pi), (y, 2)])\n",
      " |      1 + 2*pi\n",
      " |      >>> reps = [(y, x**2), (x, 2)]\n",
      " |      >>> (x + y).subs(reps)\n",
      " |      6\n",
      " |      >>> (x + y).subs(reversed(reps))\n",
      " |      x**2 + 2\n",
      " |      \n",
      " |      >>> (x**2 + x**4).subs(x**2, y)\n",
      " |      y**2 + y\n",
      " |      \n",
      " |      To replace only the x**2 but not the x**4, use xreplace:\n",
      " |      \n",
      " |      >>> (x**2 + x**4).xreplace({x**2: y})\n",
      " |      x**4 + y\n",
      " |      \n",
      " |      To delay evaluation until all substitutions have been made,\n",
      " |      set the keyword ``simultaneous`` to True:\n",
      " |      \n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)])\n",
      " |      0\n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)], simultaneous=True)\n",
      " |      nan\n",
      " |      \n",
      " |      This has the added feature of not allowing subsequent substitutions\n",
      " |      to affect those already made:\n",
      " |      \n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y})\n",
      " |      1\n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y}, simultaneous=True)\n",
      " |      y/(x + y)\n",
      " |      \n",
      " |      In order to obtain a canonical result, unordered iterables are\n",
      " |      sorted by count_op length, number of arguments and by the\n",
      " |      default_sort_key to break any ties. All other iterables are left\n",
      " |      unsorted.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, sin, cos\n",
      " |      >>> from sympy.abc import a, b, c, d, e\n",
      " |      \n",
      " |      >>> A = (sqrt(sin(2*x)), a)\n",
      " |      >>> B = (sin(2*x), b)\n",
      " |      >>> C = (cos(2*x), c)\n",
      " |      >>> D = (x, d)\n",
      " |      >>> E = (exp(x), e)\n",
      " |      \n",
      " |      >>> expr = sqrt(sin(2*x))*sin(exp(x)*x)*cos(2*x) + sin(2*x)\n",
      " |      \n",
      " |      >>> expr.subs(dict([A, B, C, D, E]))\n",
      " |      a*c*sin(d*e) + b\n",
      " |      \n",
      " |      The resulting expression represents a literal replacement of the\n",
      " |      old arguments with the new arguments. This may not reflect the\n",
      " |      limiting behavior of the expression:\n",
      " |      \n",
      " |      >>> (x**3 - 3*x).subs({x: oo})\n",
      " |      nan\n",
      " |      \n",
      " |      >>> limit(x**3 - 3*x, x, oo)\n",
      " |      oo\n",
      " |      \n",
      " |      If the substitution will be followed by numerical\n",
      " |      evaluation, it is better to pass the substitution to\n",
      " |      evalf as\n",
      " |      \n",
      " |      >>> (1/x).evalf(subs={x: 3.0}, n=21)\n",
      " |      0.333333333333333333333\n",
      " |      \n",
      " |      rather than\n",
      " |      \n",
      " |      >>> (1/x).subs({x: 3.0}).evalf(21)\n",
      " |      0.333333333333333314830\n",
      " |      \n",
      " |      as the former will ensure that the desired level of precision is\n",
      " |      obtained.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |      sympy.core.evalf.EvalfMixin.evalf: calculates the given formula to a desired level of precision\n",
      " |  \n",
      " |  xreplace(self, rule)\n",
      " |      Replace occurrences of objects within the expression.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      rule : dict-like\n",
      " |          Expresses a replacement rule\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      xreplace : the result of the replacement\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, pi, exp\n",
      " |      >>> x, y, z = symbols('x y z')\n",
      " |      >>> (1 + x*y).xreplace({x: pi})\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).xreplace({x: pi, y: 2})\n",
      " |      1 + 2*pi\n",
      " |      \n",
      " |      Replacements occur only if an entire node in the expression tree is\n",
      " |      matched:\n",
      " |      \n",
      " |      >>> (x*y + z).xreplace({x*y: pi})\n",
      " |      z + pi\n",
      " |      >>> (x*y*z).xreplace({x*y: pi})\n",
      " |      x*y*z\n",
      " |      >>> (2*x).xreplace({2*x: y, x: z})\n",
      " |      y\n",
      " |      >>> (2*2*x).xreplace({2*x: y, x: z})\n",
      " |      4*z\n",
      " |      >>> (x + y + 2).xreplace({x + y: 2})\n",
      " |      x + y + 2\n",
      " |      >>> (x + 2 + exp(x + 2)).xreplace({x + 2: y})\n",
      " |      x + exp(y) + 2\n",
      " |      \n",
      " |      xreplace doesn't differentiate between free and bound symbols. In the\n",
      " |      following, subs(x, y) would not change x since it is a bound symbol,\n",
      " |      but xreplace does:\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> Integral(x, (x, 1, 2*x)).xreplace({x: y})\n",
      " |      Integral(y, (y, 1, 2*y))\n",
      " |      \n",
      " |      Trying to replace x with an expression raises an error:\n",
      " |      \n",
      " |      >>> Integral(x, (x, 1, 2*x)).xreplace({x: 2*y}) # doctest: +SKIP\n",
      " |      ValueError: Invalid limits given: ((2*y, 1, 4*y),)\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      subs: substitution of subexpressions as defined by the objects\n",
      " |            themselves.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  class_key() from sympy.core.assumptions.ManagedProperties\n",
      " |      Nice order of classes.\n",
      " |  \n",
      " |  fromiter(args, **assumptions) from sympy.core.assumptions.ManagedProperties\n",
      " |      Create a new object from an iterable.\n",
      " |      \n",
      " |      This is a convenience function that allows one to create objects from\n",
      " |      any iterable, without having to convert to a list or tuple first.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Tuple\n",
      " |      >>> Tuple.fromiter(i for i in range(5))\n",
      " |      (0, 1, 2, 3, 4)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  args\n",
      " |      Returns a tuple of arguments of 'self'.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cot\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> cot(x).args\n",
      " |      (x,)\n",
      " |      \n",
      " |      >>> cot(x).args[0]\n",
      " |      x\n",
      " |      \n",
      " |      >>> (x*y).args\n",
      " |      (x, y)\n",
      " |      \n",
      " |      >>> (x*y).args[1]\n",
      " |      y\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Never use self._args, always use self.args.\n",
      " |      Only use _args in __new__ when creating a new function.\n",
      " |      Don't override .args() from Basic (so that it's easy to\n",
      " |      change the interface in the future if needed).\n",
      " |  \n",
      " |  assumptions0\n",
      " |      Return object `type` assumptions.\n",
      " |      \n",
      " |      For example:\n",
      " |      \n",
      " |        Symbol('x', real=True)\n",
      " |        Symbol('x', integer=True)\n",
      " |      \n",
      " |      are different objects. In other words, besides Python type (Symbol in\n",
      " |      this case), the initial assumptions are also forming their typeinfo.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True}\n",
      " |      >>> x = Symbol(\"x\", positive=True)\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True, 'complex': True, 'extended_negative': False,\n",
      " |       'extended_nonnegative': True, 'extended_nonpositive': False,\n",
      " |       'extended_nonzero': True, 'extended_positive': True, 'extended_real':\n",
      " |       True, 'finite': True, 'hermitian': True, 'imaginary': False,\n",
      " |       'infinite': False, 'negative': False, 'nonnegative': True,\n",
      " |       'nonpositive': False, 'nonzero': True, 'positive': True, 'real':\n",
      " |       True, 'zero': False}\n",
      " |  \n",
      " |  canonical_variables\n",
      " |      Return a dictionary mapping any variable defined in\n",
      " |      ``self.bound_symbols`` to Symbols that do not clash\n",
      " |      with any free symbols in the expression.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> Lambda(x, 2*x).canonical_variables\n",
      " |      {x: _0}\n",
      " |  \n",
      " |  expr_free_symbols\n",
      " |  \n",
      " |  free_symbols\n",
      " |      Return from the atoms of self those which are free symbols.\n",
      " |      \n",
      " |      For most expressions, all symbols are free symbols. For some classes\n",
      " |      this is not true. e.g. Integrals use Symbols for the dummy variables\n",
      " |      which are bound variables, so Integral has a method to return all\n",
      " |      symbols except those. Derivative keeps track of symbols with respect\n",
      " |      to which it will perform a derivative; those are\n",
      " |      bound variables, too, so it has its own free_symbols method.\n",
      " |      \n",
      " |      Any other method that uses bound variables should implement a\n",
      " |      free_symbols method.\n",
      " |  \n",
      " |  func\n",
      " |      The top-level function in an expression.\n",
      " |      \n",
      " |      The following should hold for all objects::\n",
      " |      \n",
      " |          >> x == x.func(*x.args)\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> a = 2*x\n",
      " |      >>> a.func\n",
      " |      <class 'sympy.core.mul.Mul'>\n",
      " |      >>> a.args\n",
      " |      (2, x)\n",
      " |      >>> a.func(*a.args)\n",
      " |      2*x\n",
      " |      >>> a == a.func(*a.args)\n",
      " |      True\n",
      " |  \n",
      " |  is_algebraic\n",
      " |  \n",
      " |  is_antihermitian\n",
      " |  \n",
      " |  is_commutative\n",
      " |  \n",
      " |  is_comparable\n",
      " |      Return True if self can be computed to a real number\n",
      " |      (or already is a real number) with precision, else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import exp_polar, pi, I\n",
      " |      >>> (I*exp_polar(I*pi/2)).is_comparable\n",
      " |      True\n",
      " |      >>> (I*exp_polar(I*pi*2)).is_comparable\n",
      " |      False\n",
      " |      \n",
      " |      A False result does not mean that `self` cannot be rewritten\n",
      " |      into a form that would be comparable. For example, the\n",
      " |      difference computed below is zero but without simplification\n",
      " |      it does not evaluate to a zero with precision:\n",
      " |      \n",
      " |      >>> e = 2**pi*(1 + 2**pi)\n",
      " |      >>> dif = e - e.expand()\n",
      " |      >>> dif.is_comparable\n",
      " |      False\n",
      " |      >>> dif.n(2)._prec\n",
      " |      1\n",
      " |  \n",
      " |  is_complex\n",
      " |  \n",
      " |  is_composite\n",
      " |  \n",
      " |  is_even\n",
      " |  \n",
      " |  is_extended_negative\n",
      " |  \n",
      " |  is_extended_nonnegative\n",
      " |  \n",
      " |  is_extended_nonpositive\n",
      " |  \n",
      " |  is_extended_nonzero\n",
      " |  \n",
      " |  is_extended_positive\n",
      " |  \n",
      " |  is_extended_real\n",
      " |  \n",
      " |  is_finite\n",
      " |  \n",
      " |  is_hermitian\n",
      " |  \n",
      " |  is_imaginary\n",
      " |  \n",
      " |  is_infinite\n",
      " |  \n",
      " |  is_integer\n",
      " |  \n",
      " |  is_irrational\n",
      " |  \n",
      " |  is_negative\n",
      " |  \n",
      " |  is_noninteger\n",
      " |  \n",
      " |  is_nonnegative\n",
      " |  \n",
      " |  is_nonpositive\n",
      " |  \n",
      " |  is_nonzero\n",
      " |  \n",
      " |  is_odd\n",
      " |  \n",
      " |  is_polar\n",
      " |  \n",
      " |  is_positive\n",
      " |  \n",
      " |  is_prime\n",
      " |  \n",
      " |  is_rational\n",
      " |  \n",
      " |  is_real\n",
      " |  \n",
      " |  is_transcendental\n",
      " |  \n",
      " |  is_zero\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __annotations__ = {'_args': 'Tuple[Basic, ...]', '_mhash': 'Any', 'kin...\n",
      " |  \n",
      " |  is_Add = False\n",
      " |  \n",
      " |  is_AlgebraicNumber = False\n",
      " |  \n",
      " |  is_Atom = False\n",
      " |  \n",
      " |  is_Boolean = False\n",
      " |  \n",
      " |  is_Derivative = False\n",
      " |  \n",
      " |  is_Dummy = False\n",
      " |  \n",
      " |  is_Equality = False\n",
      " |  \n",
      " |  is_Float = False\n",
      " |  \n",
      " |  is_Function = False\n",
      " |  \n",
      " |  is_Indexed = False\n",
      " |  \n",
      " |  is_Integer = False\n",
      " |  \n",
      " |  is_MatAdd = False\n",
      " |  \n",
      " |  is_MatMul = False\n",
      " |  \n",
      " |  is_Matrix = False\n",
      " |  \n",
      " |  is_Mul = False\n",
      " |  \n",
      " |  is_Not = False\n",
      " |  \n",
      " |  is_Number = False\n",
      " |  \n",
      " |  is_NumberSymbol = False\n",
      " |  \n",
      " |  is_Order = False\n",
      " |  \n",
      " |  is_Piecewise = False\n",
      " |  \n",
      " |  is_Point = False\n",
      " |  \n",
      " |  is_Poly = False\n",
      " |  \n",
      " |  is_Pow = False\n",
      " |  \n",
      " |  is_Rational = False\n",
      " |  \n",
      " |  is_Relational = False\n",
      " |  \n",
      " |  is_Symbol = False\n",
      " |  \n",
      " |  is_Vector = False\n",
      " |  \n",
      " |  is_Wild = False\n",
      " |  \n",
      " |  is_symbol = False\n",
      " |  \n",
      " |  kind = UndefinedKind\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.printing.defaults.Printable:\n",
      " |  \n",
      " |  __repr__ = __str__(self)\n",
      " |  \n",
      " |  __str__(self)\n",
      " |      Return str(self).\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.evalf.EvalfMixin:\n",
      " |  \n",
      " |  evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      " |      Evaluate the given formula to an accuracy of *n* digits.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      subs : dict, optional\n",
      " |          Substitute numerical values for symbols, e.g.\n",
      " |          ``subs={x:3, y:1+pi}``. The substitutions must be given as a\n",
      " |          dictionary.\n",
      " |      \n",
      " |      maxn : int, optional\n",
      " |          Allow a maximum temporary working precision of maxn digits.\n",
      " |      \n",
      " |      chop : bool or number, optional\n",
      " |          Specifies how to replace tiny real or imaginary parts in\n",
      " |          subresults by exact zeros.\n",
      " |      \n",
      " |          When ``True`` the chop value defaults to standard precision.\n",
      " |      \n",
      " |          Otherwise the chop value is used to determine the\n",
      " |          magnitude of \"small\" for purposes of chopping.\n",
      " |      \n",
      " |          >>> from sympy import N\n",
      " |          >>> x = 1e-4\n",
      " |          >>> N(x, chop=True)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-5)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-4)\n",
      " |          0\n",
      " |      \n",
      " |      strict : bool, optional\n",
      " |          Raise ``PrecisionExhausted`` if any subresult fails to\n",
      " |          evaluate to full accuracy, given the available maxprec.\n",
      " |      \n",
      " |      quad : str, optional\n",
      " |          Choose algorithm for numerical quadrature. By default,\n",
      " |          tanh-sinh quadrature is used. For oscillatory\n",
      " |          integrals on an infinite interval, try ``quad='osc'``.\n",
      " |      \n",
      " |      verbose : bool, optional\n",
      " |          Print debug information.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      When Floats are naively substituted into an expression,\n",
      " |      precision errors may adversely affect the result. For example,\n",
      " |      adding 1e16 (a Float) to 1 will truncate to 1e16; if 1e16 is\n",
      " |      then subtracted, the result will be 0.\n",
      " |      That is exactly what happens in the following:\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> values = {x: 1e16, y: 1, z: 1e16}\n",
      " |      >>> (x + y - z).subs(values)\n",
      " |      0\n",
      " |      \n",
      " |      Using the subs argument for evalf is the accurate way to\n",
      " |      evaluate such an expression:\n",
      " |      \n",
      " |      >>> (x + y - z).evalf(subs=values)\n",
      " |      1.00000000000000\n",
      " |  \n",
      " |  n = evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(ImageSet)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "acf41f7a",
   "metadata": {},
   "outputs": [],
   "source": [
    "A=FiniteSet(-1,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "719b170d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{x\\; \\middle|\\; x^{2} - 4 x + 3 = 0 \\right\\}$"
      ],
      "text/plain": [
       "ConditionSet(x, Eq(x**2 - 4*x + 3, 0))"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B=ConditionSet(x,Eq(x**2-4*x+3,0))\n",
    "B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "d7236bd1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{-1, 2\\right\\} \\cup \\left\\{x\\; \\middle|\\; x^{2} - 4 x + 3 = 0 \\right\\}$"
      ],
      "text/plain": [
       "Union(ConditionSet(x, Eq(x**2 - 4*x + 3, 0)), {-1, 2})"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(A+B)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "60eaae4b",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\sin{\\left(3 \\right)}$"
      ],
      "text/plain": [
       "sin(3)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sin(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "cbc606c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[-1, 2\\right]$"
      ],
      "text/plain": [
       "Interval(-1, 2)"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset((x**2<=x+2),x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "06694fdf",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class Piecewise in module sympy.functions.elementary.piecewise:\n",
      "\n",
      "class Piecewise(sympy.core.function.Function)\n",
      " |  Piecewise(*_args)\n",
      " |  \n",
      " |  Represents a piecewise function.\n",
      " |  \n",
      " |  Usage:\n",
      " |  \n",
      " |    Piecewise( (expr,cond), (expr,cond), ... )\n",
      " |      - Each argument is a 2-tuple defining an expression and condition\n",
      " |      - The conds are evaluated in turn returning the first that is True.\n",
      " |        If any of the evaluated conds are not explicitly False,\n",
      " |        e.g. ``x < 1``, the function is returned in symbolic form.\n",
      " |      - If the function is evaluated at a place where all conditions are False,\n",
      " |        nan will be returned.\n",
      " |      - Pairs where the cond is explicitly False, will be removed and no pair\n",
      " |        appearing after a True condition will ever be retained. If a single\n",
      " |        pair with a True condition remains, it will be returned, even when\n",
      " |        evaluation is False.\n",
      " |  \n",
      " |  Examples\n",
      " |  ========\n",
      " |  \n",
      " |  >>> from sympy import Piecewise, log, piecewise_fold\n",
      " |  >>> from sympy.abc import x, y\n",
      " |  >>> f = x**2\n",
      " |  >>> g = log(x)\n",
      " |  >>> p = Piecewise((0, x < -1), (f, x <= 1), (g, True))\n",
      " |  >>> p.subs(x,1)\n",
      " |  1\n",
      " |  >>> p.subs(x,5)\n",
      " |  log(5)\n",
      " |  \n",
      " |  Booleans can contain Piecewise elements:\n",
      " |  \n",
      " |  >>> cond = (x < y).subs(x, Piecewise((2, x < 0), (3, True))); cond\n",
      " |  Piecewise((2, x < 0), (3, True)) < y\n",
      " |  \n",
      " |  The folded version of this results in a Piecewise whose\n",
      " |  expressions are Booleans:\n",
      " |  \n",
      " |  >>> folded_cond = piecewise_fold(cond); folded_cond\n",
      " |  Piecewise((2 < y, x < 0), (3 < y, True))\n",
      " |  \n",
      " |  When a Boolean containing Piecewise (like cond) or a Piecewise\n",
      " |  with Boolean expressions (like folded_cond) is used as a condition,\n",
      " |  it is converted to an equivalent :class:`~.ITE` object:\n",
      " |  \n",
      " |  >>> Piecewise((1, folded_cond))\n",
      " |  Piecewise((1, ITE(x < 0, y > 2, y > 3)))\n",
      " |  \n",
      " |  When a condition is an ``ITE``, it will be converted to a simplified\n",
      " |  Boolean expression:\n",
      " |  \n",
      " |  >>> piecewise_fold(_)\n",
      " |  Piecewise((1, ((x >= 0) | (y > 2)) & ((y > 3) | (x < 0))))\n",
      " |  \n",
      " |  See Also\n",
      " |  ========\n",
      " |  piecewise_fold, ITE\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      Piecewise\n",
      " |      sympy.core.function.Function\n",
      " |      sympy.core.function.Application\n",
      " |      sympy.core.expr.Expr\n",
      " |      sympy.core.basic.Basic\n",
      " |      sympy.printing.defaults.Printable\n",
      " |      sympy.core.evalf.EvalfMixin\n",
      " |      builtins.object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  as_expr_set_pairs(self, domain=None)\n",
      " |      Return tuples for each argument of self that give\n",
      " |      the expression and the interval in which it is valid\n",
      " |      which is contained within the given domain.\n",
      " |      If a condition cannot be converted to a set, an error\n",
      " |      will be raised. The variable of the conditions is\n",
      " |      assumed to be real; sets of real values are returned.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Piecewise, Interval\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> p = Piecewise(\n",
      " |      ...     (1, x < 2),\n",
      " |      ...     (2,(x > 0) & (x < 4)),\n",
      " |      ...     (3, True))\n",
      " |      >>> p.as_expr_set_pairs()\n",
      " |      [(1, Interval.open(-oo, 2)),\n",
      " |       (2, Interval.Ropen(2, 4)),\n",
      " |       (3, Interval(4, oo))]\n",
      " |      >>> p.as_expr_set_pairs(Interval(0, 3))\n",
      " |      [(1, Interval.Ropen(0, 2)),\n",
      " |       (2, Interval(2, 3))]\n",
      " |  \n",
      " |  doit(self, **hints)\n",
      " |      Evaluate this piecewise function.\n",
      " |  \n",
      " |  piecewise_integrate(self, x, **kwargs)\n",
      " |      Return the Piecewise with each expression being\n",
      " |      replaced with its antiderivative. To obtain a continuous\n",
      " |      antiderivative, use the :func:`~.integrate` function or method.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Piecewise\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> p = Piecewise((0, x < 0), (1, x < 1), (2, True))\n",
      " |      >>> p.piecewise_integrate(x)\n",
      " |      Piecewise((0, x < 0), (x, x < 1), (2*x, True))\n",
      " |      \n",
      " |      Note that this does not give a continuous function, e.g.\n",
      " |      at x = 1 the 3rd condition applies and the antiderivative\n",
      " |      there is 2*x so the value of the antiderivative is 2:\n",
      " |      \n",
      " |      >>> anti = _\n",
      " |      >>> anti.subs(x, 1)\n",
      " |      2\n",
      " |      \n",
      " |      The continuous derivative accounts for the integral *up to*\n",
      " |      the point of interest, however:\n",
      " |      \n",
      " |      >>> p.integrate(x)\n",
      " |      Piecewise((0, x < 0), (x, x < 1), (2*x - 1, True))\n",
      " |      >>> _.subs(x, 1)\n",
      " |      1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      Piecewise._eval_integral\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods defined here:\n",
      " |  \n",
      " |  eval(*_args) from sympy.core.function.FunctionClass\n",
      " |      Either return a modified version of the args or, if no\n",
      " |      modifications were made, return None.\n",
      " |      \n",
      " |      Modifications that are made here:\n",
      " |      \n",
      " |      1. relationals are made canonical\n",
      " |      2. any False conditions are dropped\n",
      " |      3. any repeat of a previous condition is ignored\n",
      " |      4. any args past one with a true condition are dropped\n",
      " |      \n",
      " |      If there are no args left, nan will be returned.\n",
      " |      If there is a single arg with a True condition, its\n",
      " |      corresponding expression will be returned.\n",
      " |      \n",
      " |      EXAMPLES\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Piecewise\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> cond = -x < -1\n",
      " |      >>> args = [(1, cond), (4, cond), (3, False), (2, True), (5, x < 1)]\n",
      " |      >>> Piecewise(*args, evaluate=False)\n",
      " |      Piecewise((1, -x < -1), (4, -x < -1), (2, True))\n",
      " |      >>> Piecewise(*args)\n",
      " |      Piecewise((1, x > 1), (2, True))\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  __new__(cls, *args, **options)\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties defined here:\n",
      " |  \n",
      " |  __sympy__\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes defined here:\n",
      " |  \n",
      " |  default_assumptions = {}\n",
      " |  \n",
      " |  is_Piecewise = True\n",
      " |  \n",
      " |  nargs = Naturals0\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.function.Function:\n",
      " |  \n",
      " |  as_base_exp(self)\n",
      " |      Returns the method as the 2-tuple (base, exponent).\n",
      " |  \n",
      " |  fdiff(self, argindex=1)\n",
      " |      Returns the first derivative of the function.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.core.function.Function:\n",
      " |  \n",
      " |  class_key() from sympy.core.function.FunctionClass\n",
      " |      Nice order of classes.\n",
      " |  \n",
      " |  is_singular(a) from sympy.core.function.FunctionClass\n",
      " |      Tests whether the argument is an essential singularity\n",
      " |      or a branch point, or the functions is non-holomorphic.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.function.Application:\n",
      " |  \n",
      " |  func\n",
      " |      The top-level function in an expression.\n",
      " |      \n",
      " |      The following should hold for all objects::\n",
      " |      \n",
      " |          >> x == x.func(*x.args)\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> a = 2*x\n",
      " |      >>> a.func\n",
      " |      <class 'sympy.core.mul.Mul'>\n",
      " |      >>> a.args\n",
      " |      (2, x)\n",
      " |      >>> a.func(*a.args)\n",
      " |      2*x\n",
      " |      >>> a == a.func(*a.args)\n",
      " |      True\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from sympy.core.function.Application:\n",
      " |  \n",
      " |  __dict__\n",
      " |      dictionary for instance variables (if defined)\n",
      " |  \n",
      " |  __weakref__\n",
      " |      list of weak references to the object (if defined)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.function.Application:\n",
      " |  \n",
      " |  is_Function = True\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.expr.Expr:\n",
      " |  \n",
      " |  __abs__(self)\n",
      " |  \n",
      " |  __add__(self, other)\n",
      " |  \n",
      " |  __complex__(self)\n",
      " |  \n",
      " |  __divmod__(self, other)\n",
      " |  \n",
      " |  __float__(self)\n",
      " |  \n",
      " |  __floordiv__(self, other)\n",
      " |  \n",
      " |  __ge__(self, other)\n",
      " |      Return self>=value.\n",
      " |  \n",
      " |  __gt__(self, other)\n",
      " |      Return self>value.\n",
      " |  \n",
      " |  __int__(self)\n",
      " |  \n",
      " |  __le__(self, other)\n",
      " |      Return self<=value.\n",
      " |  \n",
      " |  __lt__(self, other)\n",
      " |      Return self<value.\n",
      " |  \n",
      " |  __mod__(self, other)\n",
      " |  \n",
      " |  __mul__(self, other)\n",
      " |  \n",
      " |  __neg__(self)\n",
      " |  \n",
      " |  __pos__(self)\n",
      " |  \n",
      " |  __pow__(self, other, mod=None)\n",
      " |  \n",
      " |  __radd__(self, other)\n",
      " |  \n",
      " |  __rdivmod__(self, other)\n",
      " |  \n",
      " |  __rfloordiv__(self, other)\n",
      " |  \n",
      " |  __rmod__(self, other)\n",
      " |  \n",
      " |  __rmul__(self, other)\n",
      " |  \n",
      " |  __round__ = round(self, n=None)\n",
      " |  \n",
      " |  __rpow__(self, other)\n",
      " |  \n",
      " |  __rsub__(self, other)\n",
      " |  \n",
      " |  __rtruediv__(self, other)\n",
      " |  \n",
      " |  __sub__(self, other)\n",
      " |  \n",
      " |  __truediv__(self, other)\n",
      " |  \n",
      " |  __trunc__(self)\n",
      " |  \n",
      " |  adjoint(self)\n",
      " |  \n",
      " |  apart(self, x=None, **args)\n",
      " |      See the apart function in sympy.polys\n",
      " |  \n",
      " |  args_cnc(self, cset=False, warn=True, split_1=True)\n",
      " |      Return [commutative factors, non-commutative factors] of self.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      self is treated as a Mul and the ordering of the factors is maintained.\n",
      " |      If ``cset`` is True the commutative factors will be returned in a set.\n",
      " |      If there were repeated factors (as may happen with an unevaluated Mul)\n",
      " |      then an error will be raised unless it is explicitly suppressed by\n",
      " |      setting ``warn`` to False.\n",
      " |      \n",
      " |      Note: -1 is always separated from a Number unless split_1 is False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, oo\n",
      " |      >>> A, B = symbols('A B', commutative=0)\n",
      " |      >>> x, y = symbols('x y')\n",
      " |      >>> (-2*x*y).args_cnc()\n",
      " |      [[-1, 2, x, y], []]\n",
      " |      >>> (-2.5*x).args_cnc()\n",
      " |      [[-1, 2.5, x], []]\n",
      " |      >>> (-2*x*A*B*y).args_cnc()\n",
      " |      [[-1, 2, x, y], [A, B]]\n",
      " |      >>> (-2*x*A*B*y).args_cnc(split_1=False)\n",
      " |      [[-2, x, y], [A, B]]\n",
      " |      >>> (-2*x*y).args_cnc(cset=True)\n",
      " |      [{-1, 2, x, y}, []]\n",
      " |      \n",
      " |      The arg is always treated as a Mul:\n",
      " |      \n",
      " |      >>> (-2 + x + A).args_cnc()\n",
      " |      [[], [x - 2 + A]]\n",
      " |      >>> (-oo).args_cnc() # -oo is a singleton\n",
      " |      [[-1, oo], []]\n",
      " |  \n",
      " |  as_coeff_Add(self, rational=False)\n",
      " |      Efficiently extract the coefficient of a summation.\n",
      " |  \n",
      " |  as_coeff_Mul(self, rational=False)\n",
      " |      Efficiently extract the coefficient of a product.\n",
      " |  \n",
      " |  as_coeff_add(self, *deps)\n",
      " |      Return the tuple (c, args) where self is written as an Add, ``a``.\n",
      " |      \n",
      " |      c should be a Rational added to any terms of the Add that are\n",
      " |      independent of deps.\n",
      " |      \n",
      " |      args should be a tuple of all other terms of ``a``; args is empty\n",
      " |      if self is a Number or if self is independent of deps (when given).\n",
      " |      \n",
      " |      This should be used when you do not know if self is an Add or not but\n",
      " |      you want to treat self as an Add or if you want to process the\n",
      " |      individual arguments of the tail of self as an Add.\n",
      " |      \n",
      " |      - if you know self is an Add and want only the head, use self.args[0];\n",
      " |      - if you do not want to process the arguments of the tail but need the\n",
      " |        tail then use self.as_two_terms() which gives the head and tail.\n",
      " |      - if you want to split self into an independent and dependent parts\n",
      " |        use ``self.as_independent(*deps)``\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (S(3)).as_coeff_add()\n",
      " |      (3, ())\n",
      " |      >>> (3 + x).as_coeff_add()\n",
      " |      (3, (x,))\n",
      " |      >>> (3 + x + y).as_coeff_add(x)\n",
      " |      (y + 3, (x,))\n",
      " |      >>> (3 + y).as_coeff_add(x)\n",
      " |      (y + 3, ())\n",
      " |  \n",
      " |  as_coeff_exponent(self, x)\n",
      " |      ``c*x**e -> c,e`` where x can be any symbolic expression.\n",
      " |  \n",
      " |  as_coeff_mul(self, *deps, **kwargs)\n",
      " |      Return the tuple (c, args) where self is written as a Mul, ``m``.\n",
      " |      \n",
      " |      c should be a Rational multiplied by any factors of the Mul that are\n",
      " |      independent of deps.\n",
      " |      \n",
      " |      args should be a tuple of all other factors of m; args is empty\n",
      " |      if self is a Number or if self is independent of deps (when given).\n",
      " |      \n",
      " |      This should be used when you do not know if self is a Mul or not but\n",
      " |      you want to treat self as a Mul or if you want to process the\n",
      " |      individual arguments of the tail of self as a Mul.\n",
      " |      \n",
      " |      - if you know self is a Mul and want only the head, use self.args[0];\n",
      " |      - if you do not want to process the arguments of the tail but need the\n",
      " |        tail then use self.as_two_terms() which gives the head and tail;\n",
      " |      - if you want to split self into an independent and dependent parts\n",
      " |        use ``self.as_independent(*deps)``\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (S(3)).as_coeff_mul()\n",
      " |      (3, ())\n",
      " |      >>> (3*x*y).as_coeff_mul()\n",
      " |      (3, (x, y))\n",
      " |      >>> (3*x*y).as_coeff_mul(x)\n",
      " |      (3*y, (x,))\n",
      " |      >>> (3*y).as_coeff_mul(x)\n",
      " |      (3*y, ())\n",
      " |  \n",
      " |  as_coefficient(self, expr)\n",
      " |      Extracts symbolic coefficient at the given expression. In\n",
      " |      other words, this functions separates 'self' into the product\n",
      " |      of 'expr' and 'expr'-free coefficient. If such separation\n",
      " |      is not possible it will return None.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import E, pi, sin, I, Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> E.as_coefficient(E)\n",
      " |      1\n",
      " |      >>> (2*E).as_coefficient(E)\n",
      " |      2\n",
      " |      >>> (2*sin(E)*E).as_coefficient(E)\n",
      " |      \n",
      " |      Two terms have E in them so a sum is returned. (If one were\n",
      " |      desiring the coefficient of the term exactly matching E then\n",
      " |      the constant from the returned expression could be selected.\n",
      " |      Or, for greater precision, a method of Poly can be used to\n",
      " |      indicate the desired term from which the coefficient is\n",
      " |      desired.)\n",
      " |      \n",
      " |      >>> (2*E + x*E).as_coefficient(E)\n",
      " |      x + 2\n",
      " |      >>> _.args[0]  # just want the exact match\n",
      " |      2\n",
      " |      >>> p = Poly(2*E + x*E); p\n",
      " |      Poly(x*E + 2*E, x, E, domain='ZZ')\n",
      " |      >>> p.coeff_monomial(E)\n",
      " |      2\n",
      " |      >>> p.nth(0, 1)\n",
      " |      2\n",
      " |      \n",
      " |      Since the following cannot be written as a product containing\n",
      " |      E as a factor, None is returned. (If the coefficient ``2*x`` is\n",
      " |      desired then the ``coeff`` method should be used.)\n",
      " |      \n",
      " |      >>> (2*E*x + x).as_coefficient(E)\n",
      " |      >>> (2*E*x + x).coeff(E)\n",
      " |      2*x\n",
      " |      \n",
      " |      >>> (E*(x + 1) + x).as_coefficient(E)\n",
      " |      \n",
      " |      >>> (2*pi*I).as_coefficient(pi*I)\n",
      " |      2\n",
      " |      >>> (2*I).as_coefficient(pi*I)\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      coeff: return sum of terms have a given factor\n",
      " |      as_coeff_Add: separate the additive constant from an expression\n",
      " |      as_coeff_Mul: separate the multiplicative constant from an expression\n",
      " |      as_independent: separate x-dependent terms/factors from others\n",
      " |      sympy.polys.polytools.Poly.coeff_monomial: efficiently find the single coefficient of a monomial in Poly\n",
      " |      sympy.polys.polytools.Poly.nth: like coeff_monomial but powers of monomial terms are used\n",
      " |  \n",
      " |  as_coefficients_dict(self)\n",
      " |      Return a dictionary mapping terms to their Rational coefficient.\n",
      " |      Since the dictionary is a defaultdict, inquiries about terms which\n",
      " |      were not present will return a coefficient of 0. If an expression is\n",
      " |      not an Add it is considered to have a single term.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import a, x\n",
      " |      >>> (3*x + a*x + 4).as_coefficients_dict()\n",
      " |      {1: 4, x: 3, a*x: 1}\n",
      " |      >>> _[a]\n",
      " |      0\n",
      " |      >>> (3*a*x).as_coefficients_dict()\n",
      " |      {a*x: 3}\n",
      " |  \n",
      " |  as_content_primitive(self, radical=False, clear=True)\n",
      " |      This method should recursively remove a Rational from all arguments\n",
      " |      and return that (content) and the new self (primitive). The content\n",
      " |      should always be positive and ``Mul(*foo.as_content_primitive()) == foo``.\n",
      " |      The primitive need not be in canonical form and should try to preserve\n",
      " |      the underlying structure if possible (i.e. expand_mul should not be\n",
      " |      applied to self).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sqrt\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> eq = 2 + 2*x + 2*y*(3 + 3*y)\n",
      " |      \n",
      " |      The as_content_primitive function is recursive and retains structure:\n",
      " |      \n",
      " |      >>> eq.as_content_primitive()\n",
      " |      (2, x + 3*y*(y + 1) + 1)\n",
      " |      \n",
      " |      Integer powers will have Rationals extracted from the base:\n",
      " |      \n",
      " |      >>> ((2 + 6*x)**2).as_content_primitive()\n",
      " |      (4, (3*x + 1)**2)\n",
      " |      >>> ((2 + 6*x)**(2*y)).as_content_primitive()\n",
      " |      (1, (2*(3*x + 1))**(2*y))\n",
      " |      \n",
      " |      Terms may end up joining once their as_content_primitives are added:\n",
      " |      \n",
      " |      >>> ((5*(x*(1 + y)) + 2*x*(3 + 3*y))).as_content_primitive()\n",
      " |      (11, x*(y + 1))\n",
      " |      >>> ((3*(x*(1 + y)) + 2*x*(3 + 3*y))).as_content_primitive()\n",
      " |      (9, x*(y + 1))\n",
      " |      >>> ((3*(z*(1 + y)) + 2.0*x*(3 + 3*y))).as_content_primitive()\n",
      " |      (1, 6.0*x*(y + 1) + 3*z*(y + 1))\n",
      " |      >>> ((5*(x*(1 + y)) + 2*x*(3 + 3*y))**2).as_content_primitive()\n",
      " |      (121, x**2*(y + 1)**2)\n",
      " |      >>> ((x*(1 + y) + 0.4*x*(3 + 3*y))**2).as_content_primitive()\n",
      " |      (1, 4.84*x**2*(y + 1)**2)\n",
      " |      \n",
      " |      Radical content can also be factored out of the primitive:\n",
      " |      \n",
      " |      >>> (2*sqrt(2) + 4*sqrt(10)).as_content_primitive(radical=True)\n",
      " |      (2, sqrt(2)*(1 + 2*sqrt(5)))\n",
      " |      \n",
      " |      If clear=False (default is True) then content will not be removed\n",
      " |      from an Add if it can be distributed to leave one or more\n",
      " |      terms with integer coefficients.\n",
      " |      \n",
      " |      >>> (x/2 + y).as_content_primitive()\n",
      " |      (1/2, x + 2*y)\n",
      " |      >>> (x/2 + y).as_content_primitive(clear=False)\n",
      " |      (1, x/2 + y)\n",
      " |  \n",
      " |  as_expr(self, *gens)\n",
      " |      Convert a polynomial to a SymPy expression.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> f = (x**2 + x*y).as_poly(x, y)\n",
      " |      >>> f.as_expr()\n",
      " |      x**2 + x*y\n",
      " |      \n",
      " |      >>> sin(x).as_expr()\n",
      " |      sin(x)\n",
      " |  \n",
      " |  as_independent(self, *deps, **hint)\n",
      " |      A mostly naive separation of a Mul or Add into arguments that are not\n",
      " |      are dependent on deps. To obtain as complete a separation of variables\n",
      " |      as possible, use a separation method first, e.g.:\n",
      " |      \n",
      " |      * separatevars() to change Mul, Add and Pow (including exp) into Mul\n",
      " |      * .expand(mul=True) to change Add or Mul into Add\n",
      " |      * .expand(log=True) to change log expr into an Add\n",
      " |      \n",
      " |      The only non-naive thing that is done here is to respect noncommutative\n",
      " |      ordering of variables and to always return (0, 0) for `self` of zero\n",
      " |      regardless of hints.\n",
      " |      \n",
      " |      For nonzero `self`, the returned tuple (i, d) has the\n",
      " |      following interpretation:\n",
      " |      \n",
      " |      * i will has no variable that appears in deps\n",
      " |      * d will either have terms that contain variables that are in deps, or\n",
      " |        be equal to 0 (when self is an Add) or 1 (when self is a Mul)\n",
      " |      * if self is an Add then self = i + d\n",
      " |      * if self is a Mul then self = i*d\n",
      " |      * otherwise (self, S.One) or (S.One, self) is returned.\n",
      " |      \n",
      " |      To force the expression to be treated as an Add, use the hint as_Add=True\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      -- self is an Add\n",
      " |      \n",
      " |      >>> from sympy import sin, cos, exp\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> (x + x*y).as_independent(x)\n",
      " |      (0, x*y + x)\n",
      " |      >>> (x + x*y).as_independent(y)\n",
      " |      (x, x*y)\n",
      " |      >>> (2*x*sin(x) + y + x + z).as_independent(x)\n",
      " |      (y + z, 2*x*sin(x) + x)\n",
      " |      >>> (2*x*sin(x) + y + x + z).as_independent(x, y)\n",
      " |      (z, 2*x*sin(x) + x + y)\n",
      " |      \n",
      " |      -- self is a Mul\n",
      " |      \n",
      " |      >>> (x*sin(x)*cos(y)).as_independent(x)\n",
      " |      (cos(y), x*sin(x))\n",
      " |      \n",
      " |      non-commutative terms cannot always be separated out when self is a Mul\n",
      " |      \n",
      " |      >>> from sympy import symbols\n",
      " |      >>> n1, n2, n3 = symbols('n1 n2 n3', commutative=False)\n",
      " |      >>> (n1 + n1*n2).as_independent(n2)\n",
      " |      (n1, n1*n2)\n",
      " |      >>> (n2*n1 + n1*n2).as_independent(n2)\n",
      " |      (0, n1*n2 + n2*n1)\n",
      " |      >>> (n1*n2*n3).as_independent(n1)\n",
      " |      (1, n1*n2*n3)\n",
      " |      >>> (n1*n2*n3).as_independent(n2)\n",
      " |      (n1, n2*n3)\n",
      " |      >>> ((x-n1)*(x-y)).as_independent(x)\n",
      " |      (1, (x - y)*(x - n1))\n",
      " |      \n",
      " |      -- self is anything else:\n",
      " |      \n",
      " |      >>> (sin(x)).as_independent(x)\n",
      " |      (1, sin(x))\n",
      " |      >>> (sin(x)).as_independent(y)\n",
      " |      (sin(x), 1)\n",
      " |      >>> exp(x+y).as_independent(x)\n",
      " |      (1, exp(x + y))\n",
      " |      \n",
      " |      -- force self to be treated as an Add:\n",
      " |      \n",
      " |      >>> (3*x).as_independent(x, as_Add=True)\n",
      " |      (0, 3*x)\n",
      " |      \n",
      " |      -- force self to be treated as a Mul:\n",
      " |      \n",
      " |      >>> (3+x).as_independent(x, as_Add=False)\n",
      " |      (1, x + 3)\n",
      " |      >>> (-3+x).as_independent(x, as_Add=False)\n",
      " |      (1, x - 3)\n",
      " |      \n",
      " |      Note how the below differs from the above in making the\n",
      " |      constant on the dep term positive.\n",
      " |      \n",
      " |      >>> (y*(-3+x)).as_independent(x)\n",
      " |      (y, x - 3)\n",
      " |      \n",
      " |      -- use .as_independent() for true independence testing instead\n",
      " |         of .has(). The former considers only symbols in the free\n",
      " |         symbols while the latter considers all symbols\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> I = Integral(x, (x, 1, 2))\n",
      " |      >>> I.has(x)\n",
      " |      True\n",
      " |      >>> x in I.free_symbols\n",
      " |      False\n",
      " |      >>> I.as_independent(x) == (I, 1)\n",
      " |      True\n",
      " |      >>> (I + x).as_independent(x) == (I, x)\n",
      " |      True\n",
      " |      \n",
      " |      Note: when trying to get independent terms, a separation method\n",
      " |      might need to be used first. In this case, it is important to keep\n",
      " |      track of what you send to this routine so you know how to interpret\n",
      " |      the returned values\n",
      " |      \n",
      " |      >>> from sympy import separatevars, log\n",
      " |      >>> separatevars(exp(x+y)).as_independent(x)\n",
      " |      (exp(y), exp(x))\n",
      " |      >>> (x + x*y).as_independent(y)\n",
      " |      (x, x*y)\n",
      " |      >>> separatevars(x + x*y).as_independent(y)\n",
      " |      (x, y + 1)\n",
      " |      >>> (x*(1 + y)).as_independent(y)\n",
      " |      (x, y + 1)\n",
      " |      >>> (x*(1 + y)).expand(mul=True).as_independent(y)\n",
      " |      (x, x*y)\n",
      " |      >>> a, b=symbols('a b', positive=True)\n",
      " |      >>> (log(a*b).expand(log=True)).as_independent(b)\n",
      " |      (log(a), log(b))\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      .separatevars(), .expand(log=True), sympy.core.add.Add.as_two_terms(),\n",
      " |      sympy.core.mul.Mul.as_two_terms(), .as_coeff_add(), .as_coeff_mul()\n",
      " |  \n",
      " |  as_leading_term(self, *symbols, logx=None, cdir=0)\n",
      " |      Returns the leading (nonzero) term of the series expansion of self.\n",
      " |      \n",
      " |      The _eval_as_leading_term routines are used to do this, and they must\n",
      " |      always return a non-zero value.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> (1 + x + x**2).as_leading_term(x)\n",
      " |      1\n",
      " |      >>> (1/x**2 + x + x**2).as_leading_term(x)\n",
      " |      x**(-2)\n",
      " |  \n",
      " |  as_numer_denom(self)\n",
      " |      expression -> a/b -> a, b\n",
      " |      \n",
      " |      This is just a stub that should be defined by\n",
      " |      an object's class methods to get anything else.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      normal: return ``a/b`` instead of ``(a, b)``\n",
      " |  \n",
      " |  as_ordered_factors(self, order=None)\n",
      " |      Return list of ordered factors (if Mul) else [self].\n",
      " |  \n",
      " |  as_ordered_terms(self, order=None, data=False)\n",
      " |      Transform an expression to an ordered list of terms.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin, cos\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> (sin(x)**2*cos(x) + sin(x)**2 + 1).as_ordered_terms()\n",
      " |      [sin(x)**2*cos(x), sin(x)**2, 1]\n",
      " |  \n",
      " |  as_poly(self, *gens, **args)\n",
      " |      Converts ``self`` to a polynomial or returns ``None``.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> print((x**2 + x*y).as_poly())\n",
      " |      Poly(x**2 + x*y, x, y, domain='ZZ')\n",
      " |      \n",
      " |      >>> print((x**2 + x*y).as_poly(x, y))\n",
      " |      Poly(x**2 + x*y, x, y, domain='ZZ')\n",
      " |      \n",
      " |      >>> print((x**2 + sin(y)).as_poly(x, y))\n",
      " |      None\n",
      " |  \n",
      " |  as_powers_dict(self)\n",
      " |      Return self as a dictionary of factors with each factor being\n",
      " |      treated as a power. The keys are the bases of the factors and the\n",
      " |      values, the corresponding exponents. The resulting dictionary should\n",
      " |      be used with caution if the expression is a Mul and contains non-\n",
      " |      commutative factors since the order that they appeared will be lost in\n",
      " |      the dictionary.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      as_ordered_factors: An alternative for noncommutative applications,\n",
      " |                          returning an ordered list of factors.\n",
      " |      args_cnc: Similar to as_ordered_factors, but guarantees separation\n",
      " |                of commutative and noncommutative factors.\n",
      " |  \n",
      " |  as_real_imag(self, deep=True, **hints)\n",
      " |      Performs complex expansion on 'self' and returns a tuple\n",
      " |      containing collected both real and imaginary parts. This\n",
      " |      method cannot be confused with re() and im() functions,\n",
      " |      which does not perform complex expansion at evaluation.\n",
      " |      \n",
      " |      However it is possible to expand both re() and im()\n",
      " |      functions and get exactly the same results as with\n",
      " |      a single call to this function.\n",
      " |      \n",
      " |      >>> from sympy import symbols, I\n",
      " |      \n",
      " |      >>> x, y = symbols('x,y', real=True)\n",
      " |      \n",
      " |      >>> (x + y*I).as_real_imag()\n",
      " |      (x, y)\n",
      " |      \n",
      " |      >>> from sympy.abc import z, w\n",
      " |      \n",
      " |      >>> (z + w*I).as_real_imag()\n",
      " |      (re(z) - im(w), re(w) + im(z))\n",
      " |  \n",
      " |  as_terms(self)\n",
      " |      Transform an expression to a list of terms.\n",
      " |  \n",
      " |  aseries(self, x=None, n=6, bound=0, hir=False)\n",
      " |      Asymptotic Series expansion of self.\n",
      " |      This is equivalent to ``self.series(x, oo, n)``.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      self : Expression\n",
      " |             The expression whose series is to be expanded.\n",
      " |      \n",
      " |      x : Symbol\n",
      " |          It is the variable of the expression to be calculated.\n",
      " |      \n",
      " |      n : Value\n",
      " |          The number of terms upto which the series is to be expanded.\n",
      " |      \n",
      " |      hir : Boolean\n",
      " |            Set this parameter to be True to produce hierarchical series.\n",
      " |            It stops the recursion at an early level and may provide nicer\n",
      " |            and more useful results.\n",
      " |      \n",
      " |      bound : Value, Integer\n",
      " |              Use the ``bound`` parameter to give limit on rewriting\n",
      " |              coefficients in its normalised form.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin, exp\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> e = sin(1/x + exp(-x)) - sin(1/x)\n",
      " |      \n",
      " |      >>> e.aseries(x)\n",
      " |      (1/(24*x**4) - 1/(2*x**2) + 1 + O(x**(-6), (x, oo)))*exp(-x)\n",
      " |      \n",
      " |      >>> e.aseries(x, n=3, hir=True)\n",
      " |      -exp(-2*x)*sin(1/x)/2 + exp(-x)*cos(1/x) + O(exp(-3*x), (x, oo))\n",
      " |      \n",
      " |      >>> e = exp(exp(x)/(1 - 1/x))\n",
      " |      \n",
      " |      >>> e.aseries(x)\n",
      " |      exp(exp(x)/(1 - 1/x))\n",
      " |      \n",
      " |      >>> e.aseries(x, bound=3) # doctest: +SKIP\n",
      " |      exp(exp(x)/x**2)*exp(exp(x)/x)*exp(-exp(x) + exp(x)/(1 - 1/x) - exp(x)/x - exp(x)/x**2)*exp(exp(x))\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      Expr\n",
      " |          Asymptotic series expansion of the expression.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      This algorithm is directly induced from the limit computational algorithm provided by Gruntz.\n",
      " |      It majorly uses the mrv and rewrite sub-routines. The overall idea of this algorithm is first\n",
      " |      to look for the most rapidly varying subexpression w of a given expression f and then expands f\n",
      " |      in a series in w. Then same thing is recursively done on the leading coefficient\n",
      " |      till we get constant coefficients.\n",
      " |      \n",
      " |      If the most rapidly varying subexpression of a given expression f is f itself,\n",
      " |      the algorithm tries to find a normalised representation of the mrv set and rewrites f\n",
      " |      using this normalised representation.\n",
      " |      \n",
      " |      If the expansion contains an order term, it will be either ``O(x ** (-n))`` or ``O(w ** (-n))``\n",
      " |      where ``w`` belongs to the most rapidly varying expression of ``self``.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] Gruntz, Dominik. A new algorithm for computing asymptotic series.\n",
      " |             In: Proc. 1993 Int. Symp. Symbolic and Algebraic Computation. 1993.\n",
      " |             pp. 239-244.\n",
      " |      .. [2] Gruntz thesis - p90\n",
      " |      .. [3] http://en.wikipedia.org/wiki/Asymptotic_expansion\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      Expr.aseries: See the docstring of this function for complete details of this wrapper.\n",
      " |  \n",
      " |  cancel(self, *gens, **args)\n",
      " |      See the cancel function in sympy.polys\n",
      " |  \n",
      " |  coeff(self, x, n=1, right=False, _first=True)\n",
      " |      Returns the coefficient from the term(s) containing ``x**n``. If ``n``\n",
      " |      is zero then all terms independent of ``x`` will be returned.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      When ``x`` is noncommutative, the coefficient to the left (default) or\n",
      " |      right of ``x`` can be returned. The keyword 'right' is ignored when\n",
      " |      ``x`` is commutative.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      You can select terms that have an explicit negative in front of them:\n",
      " |      \n",
      " |      >>> (-x + 2*y).coeff(-1)\n",
      " |      x\n",
      " |      >>> (x - 2*y).coeff(-1)\n",
      " |      2*y\n",
      " |      \n",
      " |      You can select terms with no Rational coefficient:\n",
      " |      \n",
      " |      >>> (x + 2*y).coeff(1)\n",
      " |      x\n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(1)\n",
      " |      0\n",
      " |      \n",
      " |      You can select terms independent of x by making n=0; in this case\n",
      " |      expr.as_independent(x)[0] is returned (and 0 will be returned instead\n",
      " |      of None):\n",
      " |      \n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(x, 0)\n",
      " |      3\n",
      " |      >>> eq = ((x + 1)**3).expand() + 1\n",
      " |      >>> eq\n",
      " |      x**3 + 3*x**2 + 3*x + 2\n",
      " |      >>> [eq.coeff(x, i) for i in reversed(range(4))]\n",
      " |      [1, 3, 3, 2]\n",
      " |      >>> eq -= 2\n",
      " |      >>> [eq.coeff(x, i) for i in reversed(range(4))]\n",
      " |      [1, 3, 3, 0]\n",
      " |      \n",
      " |      You can select terms that have a numerical term in front of them:\n",
      " |      \n",
      " |      >>> (-x - 2*y).coeff(2)\n",
      " |      -y\n",
      " |      >>> from sympy import sqrt\n",
      " |      >>> (x + sqrt(2)*x).coeff(sqrt(2))\n",
      " |      x\n",
      " |      \n",
      " |      The matching is exact:\n",
      " |      \n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(x)\n",
      " |      2\n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(x**2)\n",
      " |      4\n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(x**3)\n",
      " |      0\n",
      " |      >>> (z*(x + y)**2).coeff((x + y)**2)\n",
      " |      z\n",
      " |      >>> (z*(x + y)**2).coeff(x + y)\n",
      " |      0\n",
      " |      \n",
      " |      In addition, no factoring is done, so 1 + z*(1 + y) is not obtained\n",
      " |      from the following:\n",
      " |      \n",
      " |      >>> (x + z*(x + x*y)).coeff(x)\n",
      " |      1\n",
      " |      \n",
      " |      If such factoring is desired, factor_terms can be used first:\n",
      " |      \n",
      " |      >>> from sympy import factor_terms\n",
      " |      >>> factor_terms(x + z*(x + x*y)).coeff(x)\n",
      " |      z*(y + 1) + 1\n",
      " |      \n",
      " |      >>> n, m, o = symbols('n m o', commutative=False)\n",
      " |      >>> n.coeff(n)\n",
      " |      1\n",
      " |      >>> (3*n).coeff(n)\n",
      " |      3\n",
      " |      >>> (n*m + m*n*m).coeff(n) # = (1 + m)*n*m\n",
      " |      1 + m\n",
      " |      >>> (n*m + m*n*m).coeff(n, right=True) # = (1 + m)*n*m\n",
      " |      m\n",
      " |      \n",
      " |      If there is more than one possible coefficient 0 is returned:\n",
      " |      \n",
      " |      >>> (n*m + m*n).coeff(n)\n",
      " |      0\n",
      " |      \n",
      " |      If there is only one possible coefficient, it is returned:\n",
      " |      \n",
      " |      >>> (n*m + x*m*n).coeff(m*n)\n",
      " |      x\n",
      " |      >>> (n*m + x*m*n).coeff(m*n, right=1)\n",
      " |      1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      as_coefficient: separate the expression into a coefficient and factor\n",
      " |      as_coeff_Add: separate the additive constant from an expression\n",
      " |      as_coeff_Mul: separate the multiplicative constant from an expression\n",
      " |      as_independent: separate x-dependent terms/factors from others\n",
      " |      sympy.polys.polytools.Poly.coeff_monomial: efficiently find the single coefficient of a monomial in Poly\n",
      " |      sympy.polys.polytools.Poly.nth: like coeff_monomial but powers of monomial terms are used\n",
      " |  \n",
      " |  collect(self, syms, func=None, evaluate=True, exact=False, distribute_order_term=True)\n",
      " |      See the collect function in sympy.simplify\n",
      " |  \n",
      " |  combsimp(self)\n",
      " |      See the combsimp function in sympy.simplify\n",
      " |  \n",
      " |  compute_leading_term(self, x, logx=None)\n",
      " |      as_leading_term is only allowed for results of .series()\n",
      " |      This is a wrapper to compute a series first.\n",
      " |  \n",
      " |  conjugate(self)\n",
      " |      Returns the complex conjugate of 'self'.\n",
      " |  \n",
      " |  could_extract_minus_sign(self)\n",
      " |      Return True if self has -1 as a leading factor or has\n",
      " |      more literal negative signs than positive signs in a sum,\n",
      " |      otherwise False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> e = x - y\n",
      " |      >>> {i.could_extract_minus_sign() for i in (e, -e)}\n",
      " |      {False, True}\n",
      " |      \n",
      " |      Though the ``y - x`` is considered like ``-(x - y)``, since it\n",
      " |      is in a product without a leading factor of -1, the result is\n",
      " |      false below:\n",
      " |      \n",
      " |      >>> (x*(y - x)).could_extract_minus_sign()\n",
      " |      False\n",
      " |      \n",
      " |      To put something in canonical form wrt to sign, use `signsimp`:\n",
      " |      \n",
      " |      >>> from sympy import signsimp\n",
      " |      >>> signsimp(x*(y - x))\n",
      " |      -x*(x - y)\n",
      " |      >>> _.could_extract_minus_sign()\n",
      " |      True\n",
      " |  \n",
      " |  count_ops(self, visual=None)\n",
      " |      wrapper for count_ops that returns the operation count.\n",
      " |  \n",
      " |  diff(self, *symbols, **assumptions)\n",
      " |  \n",
      " |  dir(self, x, cdir)\n",
      " |  \n",
      " |  equals(self, other, failing_expression=False)\n",
      " |      Return True if self == other, False if it doesn't, or None. If\n",
      " |      failing_expression is True then the expression which did not simplify\n",
      " |      to a 0 will be returned instead of None.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      If ``self`` is a Number (or complex number) that is not zero, then\n",
      " |      the result is False.\n",
      " |      \n",
      " |      If ``self`` is a number and has not evaluated to zero, evalf will be\n",
      " |      used to test whether the expression evaluates to zero. If it does so\n",
      " |      and the result has significance (i.e. the precision is either -1, for\n",
      " |      a Rational result, or is greater than 1) then the evalf value will be\n",
      " |      used to return True or False.\n",
      " |  \n",
      " |  expand(self, deep=True, modulus=None, power_base=True, power_exp=True, mul=True, log=True, multinomial=True, basic=True, **hints)\n",
      " |      Expand an expression using hints.\n",
      " |      \n",
      " |      See the docstring of the expand() function in sympy.core.function for\n",
      " |      more information.\n",
      " |  \n",
      " |  extract_additively(self, c)\n",
      " |      Return self - c if it's possible to subtract c from self and\n",
      " |      make all matching coefficients move towards zero, else return None.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> e = 2*x + 3\n",
      " |      >>> e.extract_additively(x + 1)\n",
      " |      x + 2\n",
      " |      >>> e.extract_additively(3*x)\n",
      " |      >>> e.extract_additively(4)\n",
      " |      >>> (y*(x + 1)).extract_additively(x + 1)\n",
      " |      >>> ((x + 1)*(x + 2*y + 1) + 3).extract_additively(x + 1)\n",
      " |      (x + 1)*(x + 2*y) + 3\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      extract_multiplicatively\n",
      " |      coeff\n",
      " |      as_coefficient\n",
      " |  \n",
      " |  extract_branch_factor(self, allow_half=False)\n",
      " |      Try to write self as ``exp_polar(2*pi*I*n)*z`` in a nice way.\n",
      " |      Return (z, n).\n",
      " |      \n",
      " |      >>> from sympy import exp_polar, I, pi\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> exp_polar(I*pi).extract_branch_factor()\n",
      " |      (exp_polar(I*pi), 0)\n",
      " |      >>> exp_polar(2*I*pi).extract_branch_factor()\n",
      " |      (1, 1)\n",
      " |      >>> exp_polar(-pi*I).extract_branch_factor()\n",
      " |      (exp_polar(I*pi), -1)\n",
      " |      >>> exp_polar(3*pi*I + x).extract_branch_factor()\n",
      " |      (exp_polar(x + I*pi), 1)\n",
      " |      >>> (y*exp_polar(-5*pi*I)*exp_polar(3*pi*I + 2*pi*x)).extract_branch_factor()\n",
      " |      (y*exp_polar(2*pi*x), -1)\n",
      " |      >>> exp_polar(-I*pi/2).extract_branch_factor()\n",
      " |      (exp_polar(-I*pi/2), 0)\n",
      " |      \n",
      " |      If allow_half is True, also extract exp_polar(I*pi):\n",
      " |      \n",
      " |      >>> exp_polar(I*pi).extract_branch_factor(allow_half=True)\n",
      " |      (1, 1/2)\n",
      " |      >>> exp_polar(2*I*pi).extract_branch_factor(allow_half=True)\n",
      " |      (1, 1)\n",
      " |      >>> exp_polar(3*I*pi).extract_branch_factor(allow_half=True)\n",
      " |      (1, 3/2)\n",
      " |      >>> exp_polar(-I*pi).extract_branch_factor(allow_half=True)\n",
      " |      (1, -1/2)\n",
      " |  \n",
      " |  extract_multiplicatively(self, c)\n",
      " |      Return None if it's not possible to make self in the form\n",
      " |      c * something in a nice way, i.e. preserving the properties\n",
      " |      of arguments of self.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, Rational\n",
      " |      \n",
      " |      >>> x, y = symbols('x,y', real=True)\n",
      " |      \n",
      " |      >>> ((x*y)**3).extract_multiplicatively(x**2 * y)\n",
      " |      x*y**2\n",
      " |      \n",
      " |      >>> ((x*y)**3).extract_multiplicatively(x**4 * y)\n",
      " |      \n",
      " |      >>> (2*x).extract_multiplicatively(2)\n",
      " |      x\n",
      " |      \n",
      " |      >>> (2*x).extract_multiplicatively(3)\n",
      " |      \n",
      " |      >>> (Rational(1, 2)*x).extract_multiplicatively(3)\n",
      " |      x/6\n",
      " |  \n",
      " |  factor(self, *gens, **args)\n",
      " |      See the factor() function in sympy.polys.polytools\n",
      " |  \n",
      " |  fourier_series(self, limits=None)\n",
      " |      Compute fourier sine/cosine series of self.\n",
      " |      \n",
      " |      See the docstring of the :func:`fourier_series` in sympy.series.fourier\n",
      " |      for more information.\n",
      " |  \n",
      " |  fps(self, x=None, x0=0, dir=1, hyper=True, order=4, rational=True, full=False)\n",
      " |      Compute formal power power series of self.\n",
      " |      \n",
      " |      See the docstring of the :func:`fps` function in sympy.series.formal for\n",
      " |      more information.\n",
      " |  \n",
      " |  gammasimp(self)\n",
      " |      See the gammasimp function in sympy.simplify\n",
      " |  \n",
      " |  getO(self)\n",
      " |      Returns the additive O(..) symbol if there is one, else None.\n",
      " |  \n",
      " |  getn(self)\n",
      " |      Returns the order of the expression.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      The order is determined either from the O(...) term. If there\n",
      " |      is no O(...) term, it returns None.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import O\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> (1 + x + O(x**2)).getn()\n",
      " |      2\n",
      " |      >>> (1 + x).getn()\n",
      " |  \n",
      " |  integrate(self, *args, **kwargs)\n",
      " |      See the integrate function in sympy.integrals\n",
      " |  \n",
      " |  invert(self, g, *gens, **args)\n",
      " |      Return the multiplicative inverse of ``self`` mod ``g``\n",
      " |      where ``self`` (and ``g``) may be symbolic expressions).\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      sympy.core.numbers.mod_inverse, sympy.polys.polytools.invert\n",
      " |  \n",
      " |  is_algebraic_expr(self, *syms)\n",
      " |      This tests whether a given expression is algebraic or not, in the\n",
      " |      given symbols, syms. When syms is not given, all free symbols\n",
      " |      will be used. The rational function does not have to be in expanded\n",
      " |      or in any kind of canonical form.\n",
      " |      \n",
      " |      This function returns False for expressions that are \"algebraic\n",
      " |      expressions\" with symbolic exponents. This is a simple extension to the\n",
      " |      is_rational_function, including rational exponentiation.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol, sqrt\n",
      " |      >>> x = Symbol('x', real=True)\n",
      " |      >>> sqrt(1 + x).is_rational_function()\n",
      " |      False\n",
      " |      >>> sqrt(1 + x).is_algebraic_expr()\n",
      " |      True\n",
      " |      \n",
      " |      This function does not attempt any nontrivial simplifications that may\n",
      " |      result in an expression that does not appear to be an algebraic\n",
      " |      expression to become one.\n",
      " |      \n",
      " |      >>> from sympy import exp, factor\n",
      " |      >>> a = sqrt(exp(x)**2 + 2*exp(x) + 1)/(exp(x) + 1)\n",
      " |      >>> a.is_algebraic_expr(x)\n",
      " |      False\n",
      " |      >>> factor(a).is_algebraic_expr()\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      is_rational_function()\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Algebraic_expression\n",
      " |  \n",
      " |  is_constant(self, *wrt, **flags)\n",
      " |      Return True if self is constant, False if not, or None if\n",
      " |      the constancy could not be determined conclusively.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      If an expression has no free symbols then it is a constant. If\n",
      " |      there are free symbols it is possible that the expression is a\n",
      " |      constant, perhaps (but not necessarily) zero. To test such\n",
      " |      expressions, a few strategies are tried:\n",
      " |      \n",
      " |      1) numerical evaluation at two random points. If two such evaluations\n",
      " |      give two different values and the values have a precision greater than\n",
      " |      1 then self is not constant. If the evaluations agree or could not be\n",
      " |      obtained with any precision, no decision is made. The numerical testing\n",
      " |      is done only if ``wrt`` is different than the free symbols.\n",
      " |      \n",
      " |      2) differentiation with respect to variables in 'wrt' (or all free\n",
      " |      symbols if omitted) to see if the expression is constant or not. This\n",
      " |      will not always lead to an expression that is zero even though an\n",
      " |      expression is constant (see added test in test_expr.py). If\n",
      " |      all derivatives are zero then self is constant with respect to the\n",
      " |      given symbols.\n",
      " |      \n",
      " |      3) finding out zeros of denominator expression with free_symbols.\n",
      " |      It will not be constant if there are zeros. It gives more negative\n",
      " |      answers for expression that are not constant.\n",
      " |      \n",
      " |      If neither evaluation nor differentiation can prove the expression is\n",
      " |      constant, None is returned unless two numerical values happened to be\n",
      " |      the same and the flag ``failing_number`` is True -- in that case the\n",
      " |      numerical value will be returned.\n",
      " |      \n",
      " |      If flag simplify=False is passed, self will not be simplified;\n",
      " |      the default is True since self should be simplified before testing.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cos, sin, Sum, S, pi\n",
      " |      >>> from sympy.abc import a, n, x, y\n",
      " |      >>> x.is_constant()\n",
      " |      False\n",
      " |      >>> S(2).is_constant()\n",
      " |      True\n",
      " |      >>> Sum(x, (x, 1, 10)).is_constant()\n",
      " |      True\n",
      " |      >>> Sum(x, (x, 1, n)).is_constant()\n",
      " |      False\n",
      " |      >>> Sum(x, (x, 1, n)).is_constant(y)\n",
      " |      True\n",
      " |      >>> Sum(x, (x, 1, n)).is_constant(n)\n",
      " |      False\n",
      " |      >>> Sum(x, (x, 1, n)).is_constant(x)\n",
      " |      True\n",
      " |      >>> eq = a*cos(x)**2 + a*sin(x)**2 - a\n",
      " |      >>> eq.is_constant()\n",
      " |      True\n",
      " |      >>> eq.subs({x: pi, a: 2}) == eq.subs({x: pi, a: 3}) == 0\n",
      " |      True\n",
      " |      \n",
      " |      >>> (0**x).is_constant()\n",
      " |      False\n",
      " |      >>> x.is_constant()\n",
      " |      False\n",
      " |      >>> (x**x).is_constant()\n",
      " |      False\n",
      " |      >>> one = cos(x)**2 + sin(x)**2\n",
      " |      >>> one.is_constant()\n",
      " |      True\n",
      " |      >>> ((one - 1)**(x + 1)).is_constant() in (True, False) # could be 0 or 1\n",
      " |      True\n",
      " |  \n",
      " |  is_meromorphic(self, x, a)\n",
      " |      This tests whether an expression is meromorphic as\n",
      " |      a function of the given symbol ``x`` at the point ``a``.\n",
      " |      \n",
      " |      This method is intended as a quick test that will return\n",
      " |      None if no decision can be made without simplification or\n",
      " |      more detailed analysis.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import zoo, log, sin, sqrt\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = 1/x**2 + 1 - 2*x**3\n",
      " |      >>> f.is_meromorphic(x, 0)\n",
      " |      True\n",
      " |      >>> f.is_meromorphic(x, 1)\n",
      " |      True\n",
      " |      >>> f.is_meromorphic(x, zoo)\n",
      " |      True\n",
      " |      \n",
      " |      >>> g = x**log(3)\n",
      " |      >>> g.is_meromorphic(x, 0)\n",
      " |      False\n",
      " |      >>> g.is_meromorphic(x, 1)\n",
      " |      True\n",
      " |      >>> g.is_meromorphic(x, zoo)\n",
      " |      False\n",
      " |      \n",
      " |      >>> h = sin(1/x)*x**2\n",
      " |      >>> h.is_meromorphic(x, 0)\n",
      " |      False\n",
      " |      >>> h.is_meromorphic(x, 1)\n",
      " |      True\n",
      " |      >>> h.is_meromorphic(x, zoo)\n",
      " |      True\n",
      " |      \n",
      " |      Multivalued functions are considered meromorphic when their\n",
      " |      branches are meromorphic. Thus most functions are meromorphic\n",
      " |      everywhere except at essential singularities and branch points.\n",
      " |      In particular, they will be meromorphic also on branch cuts\n",
      " |      except at their endpoints.\n",
      " |      \n",
      " |      >>> log(x).is_meromorphic(x, -1)\n",
      " |      True\n",
      " |      >>> log(x).is_meromorphic(x, 0)\n",
      " |      False\n",
      " |      >>> sqrt(x).is_meromorphic(x, -1)\n",
      " |      True\n",
      " |      >>> sqrt(x).is_meromorphic(x, 0)\n",
      " |      False\n",
      " |  \n",
      " |  is_polynomial(self, *syms)\n",
      " |      Return True if self is a polynomial in syms and False otherwise.\n",
      " |      \n",
      " |      This checks if self is an exact polynomial in syms.  This function\n",
      " |      returns False for expressions that are \"polynomials\" with symbolic\n",
      " |      exponents.  Thus, you should be able to apply polynomial algorithms to\n",
      " |      expressions for which this returns True, and Poly(expr, \\*syms) should\n",
      " |      work if and only if expr.is_polynomial(\\*syms) returns True. The\n",
      " |      polynomial does not have to be in expanded form.  If no symbols are\n",
      " |      given, all free symbols in the expression will be used.\n",
      " |      \n",
      " |      This is not part of the assumptions system.  You cannot do\n",
      " |      Symbol('z', polynomial=True).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol, Function\n",
      " |      >>> x = Symbol('x')\n",
      " |      >>> ((x**2 + 1)**4).is_polynomial(x)\n",
      " |      True\n",
      " |      >>> ((x**2 + 1)**4).is_polynomial()\n",
      " |      True\n",
      " |      >>> (2**x + 1).is_polynomial(x)\n",
      " |      False\n",
      " |      >>> (2**x + 1).is_polynomial(2**x)\n",
      " |      True\n",
      " |      >>> f = Function('f')\n",
      " |      >>> (f(x) + 1).is_polynomial(x)\n",
      " |      False\n",
      " |      >>> (f(x) + 1).is_polynomial(f(x))\n",
      " |      True\n",
      " |      >>> (1/f(x) + 1).is_polynomial(f(x))\n",
      " |      False\n",
      " |      \n",
      " |      >>> n = Symbol('n', nonnegative=True, integer=True)\n",
      " |      >>> (x**n + 1).is_polynomial(x)\n",
      " |      False\n",
      " |      \n",
      " |      This function does not attempt any nontrivial simplifications that may\n",
      " |      result in an expression that does not appear to be a polynomial to\n",
      " |      become one.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, factor, cancel\n",
      " |      >>> y = Symbol('y', positive=True)\n",
      " |      >>> a = sqrt(y**2 + 2*y + 1)\n",
      " |      >>> a.is_polynomial(y)\n",
      " |      False\n",
      " |      >>> factor(a)\n",
      " |      y + 1\n",
      " |      >>> factor(a).is_polynomial(y)\n",
      " |      True\n",
      " |      \n",
      " |      >>> b = (y**2 + 2*y + 1)/(y + 1)\n",
      " |      >>> b.is_polynomial(y)\n",
      " |      False\n",
      " |      >>> cancel(b)\n",
      " |      y + 1\n",
      " |      >>> cancel(b).is_polynomial(y)\n",
      " |      True\n",
      " |      \n",
      " |      See also .is_rational_function()\n",
      " |  \n",
      " |  is_rational_function(self, *syms)\n",
      " |      Test whether function is a ratio of two polynomials in the given\n",
      " |      symbols, syms. When syms is not given, all free symbols will be used.\n",
      " |      The rational function does not have to be in expanded or in any kind of\n",
      " |      canonical form.\n",
      " |      \n",
      " |      This function returns False for expressions that are \"rational\n",
      " |      functions\" with symbolic exponents.  Thus, you should be able to call\n",
      " |      .as_numer_denom() and apply polynomial algorithms to the result for\n",
      " |      expressions for which this returns True.\n",
      " |      \n",
      " |      This is not part of the assumptions system.  You cannot do\n",
      " |      Symbol('z', rational_function=True).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol, sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> (x/y).is_rational_function()\n",
      " |      True\n",
      " |      \n",
      " |      >>> (x**2).is_rational_function()\n",
      " |      True\n",
      " |      \n",
      " |      >>> (x/sin(y)).is_rational_function(y)\n",
      " |      False\n",
      " |      \n",
      " |      >>> n = Symbol('n', integer=True)\n",
      " |      >>> (x**n + 1).is_rational_function(x)\n",
      " |      False\n",
      " |      \n",
      " |      This function does not attempt any nontrivial simplifications that may\n",
      " |      result in an expression that does not appear to be a rational function\n",
      " |      to become one.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, factor\n",
      " |      >>> y = Symbol('y', positive=True)\n",
      " |      >>> a = sqrt(y**2 + 2*y + 1)/y\n",
      " |      >>> a.is_rational_function(y)\n",
      " |      False\n",
      " |      >>> factor(a)\n",
      " |      (y + 1)/y\n",
      " |      >>> factor(a).is_rational_function(y)\n",
      " |      True\n",
      " |      \n",
      " |      See also is_algebraic_expr().\n",
      " |  \n",
      " |  leadterm(self, x, logx=None, cdir=0)\n",
      " |      Returns the leading term a*x**b as a tuple (a, b).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> (1+x+x**2).leadterm(x)\n",
      " |      (1, 0)\n",
      " |      >>> (1/x**2+x+x**2).leadterm(x)\n",
      " |      (1, -2)\n",
      " |  \n",
      " |  limit(self, x, xlim, dir='+')\n",
      " |      Compute limit x->xlim.\n",
      " |  \n",
      " |  lseries(self, x=None, x0=0, dir='+', logx=None, cdir=0)\n",
      " |      Wrapper for series yielding an iterator of the terms of the series.\n",
      " |      \n",
      " |      Note: an infinite series will yield an infinite iterator. The following,\n",
      " |      for exaxmple, will never terminate. It will just keep printing terms\n",
      " |      of the sin(x) series::\n",
      " |      \n",
      " |        for term in sin(x).lseries(x):\n",
      " |            print term\n",
      " |      \n",
      " |      The advantage of lseries() over nseries() is that many times you are\n",
      " |      just interested in the next term in the series (i.e. the first term for\n",
      " |      example), but you do not know how many you should ask for in nseries()\n",
      " |      using the \"n\" parameter.\n",
      " |      \n",
      " |      See also nseries().\n",
      " |  \n",
      " |  normal(self)\n",
      " |      expression -> a/b\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      as_numer_denom: return ``(a, b)`` instead of ``a/b``\n",
      " |  \n",
      " |  nseries(self, x=None, x0=0, n=6, dir='+', logx=None, cdir=0)\n",
      " |      Wrapper to _eval_nseries if assumptions allow, else to series.\n",
      " |      \n",
      " |      If x is given, x0 is 0, dir='+', and self has x, then _eval_nseries is\n",
      " |      called. This calculates \"n\" terms in the innermost expressions and\n",
      " |      then builds up the final series just by \"cross-multiplying\" everything\n",
      " |      out.\n",
      " |      \n",
      " |      The optional ``logx`` parameter can be used to replace any log(x) in the\n",
      " |      returned series with a symbolic value to avoid evaluating log(x) at 0. A\n",
      " |      symbol to use in place of log(x) should be provided.\n",
      " |      \n",
      " |      Advantage -- it's fast, because we do not have to determine how many\n",
      " |      terms we need to calculate in advance.\n",
      " |      \n",
      " |      Disadvantage -- you may end up with less terms than you may have\n",
      " |      expected, but the O(x**n) term appended will always be correct and\n",
      " |      so the result, though perhaps shorter, will also be correct.\n",
      " |      \n",
      " |      If any of those assumptions is not met, this is treated like a\n",
      " |      wrapper to series which will try harder to return the correct\n",
      " |      number of terms.\n",
      " |      \n",
      " |      See also lseries().\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin, log, Symbol\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> sin(x).nseries(x, 0, 6)\n",
      " |      x - x**3/6 + x**5/120 + O(x**6)\n",
      " |      >>> log(x+1).nseries(x, 0, 5)\n",
      " |      x - x**2/2 + x**3/3 - x**4/4 + O(x**5)\n",
      " |      \n",
      " |      Handling of the ``logx`` parameter --- in the following example the\n",
      " |      expansion fails since ``sin`` does not have an asymptotic expansion\n",
      " |      at -oo (the limit of log(x) as x approaches 0):\n",
      " |      \n",
      " |      >>> e = sin(log(x))\n",
      " |      >>> e.nseries(x, 0, 6)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      PoleError: ...\n",
      " |      ...\n",
      " |      >>> logx = Symbol('logx')\n",
      " |      >>> e.nseries(x, 0, 6, logx=logx)\n",
      " |      sin(logx)\n",
      " |      \n",
      " |      In the following example, the expansion works but gives only an Order term\n",
      " |      unless the ``logx`` parameter is used:\n",
      " |      \n",
      " |      >>> e = x**y\n",
      " |      >>> e.nseries(x, 0, 2)\n",
      " |      O(log(x)**2)\n",
      " |      >>> e.nseries(x, 0, 2, logx=logx)\n",
      " |      exp(logx*y)\n",
      " |  \n",
      " |  nsimplify(self, constants=(), tolerance=None, full=False)\n",
      " |      See the nsimplify function in sympy.simplify\n",
      " |  \n",
      " |  powsimp(self, *args, **kwargs)\n",
      " |      See the powsimp function in sympy.simplify\n",
      " |  \n",
      " |  primitive(self)\n",
      " |      Return the positive Rational that can be extracted non-recursively\n",
      " |      from every term of self (i.e., self is treated like an Add). This is\n",
      " |      like the as_coeff_Mul() method but primitive always extracts a positive\n",
      " |      Rational (never a negative or a Float).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> (3*(x + 1)**2).primitive()\n",
      " |      (3, (x + 1)**2)\n",
      " |      >>> a = (6*x + 2); a.primitive()\n",
      " |      (2, 3*x + 1)\n",
      " |      >>> b = (x/2 + 3); b.primitive()\n",
      " |      (1/2, x + 6)\n",
      " |      >>> (a*b).primitive() == (1, a*b)\n",
      " |      True\n",
      " |  \n",
      " |  radsimp(self, **kwargs)\n",
      " |      See the radsimp function in sympy.simplify\n",
      " |  \n",
      " |  ratsimp(self)\n",
      " |      See the ratsimp function in sympy.simplify\n",
      " |  \n",
      " |  removeO(self)\n",
      " |      Removes the additive O(..) symbol if there is one\n",
      " |  \n",
      " |  round(self, n=None)\n",
      " |      Return x rounded to the given decimal place.\n",
      " |      \n",
      " |      If a complex number would results, apply round to the real\n",
      " |      and imaginary components of the number.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import pi, E, I, S, Number\n",
      " |      >>> pi.round()\n",
      " |      3\n",
      " |      >>> pi.round(2)\n",
      " |      3.14\n",
      " |      >>> (2*pi + E*I).round()\n",
      " |      6 + 3*I\n",
      " |      \n",
      " |      The round method has a chopping effect:\n",
      " |      \n",
      " |      >>> (2*pi + I/10).round()\n",
      " |      6\n",
      " |      >>> (pi/10 + 2*I).round()\n",
      " |      2*I\n",
      " |      >>> (pi/10 + E*I).round(2)\n",
      " |      0.31 + 2.72*I\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      The Python ``round`` function uses the SymPy ``round`` method so it\n",
      " |      will always return a SymPy number (not a Python float or int):\n",
      " |      \n",
      " |      >>> isinstance(round(S(123), -2), Number)\n",
      " |      True\n",
      " |  \n",
      " |  separate(self, deep=False, force=False)\n",
      " |      See the separate function in sympy.simplify\n",
      " |  \n",
      " |  series(self, x=None, x0=0, n=6, dir='+', logx=None, cdir=0)\n",
      " |      Series expansion of \"self\" around ``x = x0`` yielding either terms of\n",
      " |      the series one by one (the lazy series given when n=None), else\n",
      " |      all the terms at once when n != None.\n",
      " |      \n",
      " |      Returns the series expansion of \"self\" around the point ``x = x0``\n",
      " |      with respect to ``x`` up to ``O((x - x0)**n, x, x0)`` (default n is 6).\n",
      " |      \n",
      " |      If ``x=None`` and ``self`` is univariate, the univariate symbol will\n",
      " |      be supplied, otherwise an error will be raised.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      expr : Expression\n",
      " |             The expression whose series is to be expanded.\n",
      " |      \n",
      " |      x : Symbol\n",
      " |          It is the variable of the expression to be calculated.\n",
      " |      \n",
      " |      x0 : Value\n",
      " |           The value around which ``x`` is calculated. Can be any value\n",
      " |           from ``-oo`` to ``oo``.\n",
      " |      \n",
      " |      n : Value\n",
      " |          The number of terms upto which the series is to be expanded.\n",
      " |      \n",
      " |      dir : String, optional\n",
      " |            The series-expansion can be bi-directional. If ``dir=\"+\"``,\n",
      " |            then (x->x0+). If ``dir=\"-\", then (x->x0-). For infinite\n",
      " |            ``x0`` (``oo`` or ``-oo``), the ``dir`` argument is determined\n",
      " |            from the direction of the infinity (i.e., ``dir=\"-\"`` for\n",
      " |            ``oo``).\n",
      " |      \n",
      " |      logx : optional\n",
      " |             It is used to replace any log(x) in the returned series with a\n",
      " |             symbolic value rather than evaluating the actual value.\n",
      " |      \n",
      " |      cdir : optional\n",
      " |             It stands for complex direction, and indicates the direction\n",
      " |             from which the expansion needs to be evaluated.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cos, exp, tan\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> cos(x).series()\n",
      " |      1 - x**2/2 + x**4/24 + O(x**6)\n",
      " |      >>> cos(x).series(n=4)\n",
      " |      1 - x**2/2 + O(x**4)\n",
      " |      >>> cos(x).series(x, x0=1, n=2)\n",
      " |      cos(1) - (x - 1)*sin(1) + O((x - 1)**2, (x, 1))\n",
      " |      >>> e = cos(x + exp(y))\n",
      " |      >>> e.series(y, n=2)\n",
      " |      cos(x + 1) - y*sin(x + 1) + O(y**2)\n",
      " |      >>> e.series(x, n=2)\n",
      " |      cos(exp(y)) - x*sin(exp(y)) + O(x**2)\n",
      " |      \n",
      " |      If ``n=None`` then a generator of the series terms will be returned.\n",
      " |      \n",
      " |      >>> term=cos(x).series(n=None)\n",
      " |      >>> [next(term) for i in range(2)]\n",
      " |      [1, -x**2/2]\n",
      " |      \n",
      " |      For ``dir=+`` (default) the series is calculated from the right and\n",
      " |      for ``dir=-`` the series from the left. For smooth functions this\n",
      " |      flag will not alter the results.\n",
      " |      \n",
      " |      >>> abs(x).series(dir=\"+\")\n",
      " |      x\n",
      " |      >>> abs(x).series(dir=\"-\")\n",
      " |      -x\n",
      " |      >>> f = tan(x)\n",
      " |      >>> f.series(x, 2, 6, \"+\")\n",
      " |      tan(2) + (1 + tan(2)**2)*(x - 2) + (x - 2)**2*(tan(2)**3 + tan(2)) +\n",
      " |      (x - 2)**3*(1/3 + 4*tan(2)**2/3 + tan(2)**4) + (x - 2)**4*(tan(2)**5 +\n",
      " |      5*tan(2)**3/3 + 2*tan(2)/3) + (x - 2)**5*(2/15 + 17*tan(2)**2/15 +\n",
      " |      2*tan(2)**4 + tan(2)**6) + O((x - 2)**6, (x, 2))\n",
      " |      \n",
      " |      >>> f.series(x, 2, 3, \"-\")\n",
      " |      tan(2) + (2 - x)*(-tan(2)**2 - 1) + (2 - x)**2*(tan(2)**3 + tan(2))\n",
      " |      + O((x - 2)**3, (x, 2))\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      Expr : Expression\n",
      " |          Series expansion of the expression about x0\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      TypeError\n",
      " |          If \"n\" and \"x0\" are infinity objects\n",
      " |      \n",
      " |      PoleError\n",
      " |          If \"x0\" is an infinity object\n",
      " |  \n",
      " |  sort_key(self, order=None)\n",
      " |      Return a sort key.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import S, I\n",
      " |      \n",
      " |      >>> sorted([S(1)/2, I, -I], key=lambda x: x.sort_key())\n",
      " |      [1/2, -I, I]\n",
      " |      \n",
      " |      >>> S(\"[x, 1/x, 1/x**2, x**2, x**(1/2), x**(1/4), x**(3/2)]\")\n",
      " |      [x, 1/x, x**(-2), x**2, sqrt(x), x**(1/4), x**(3/2)]\n",
      " |      >>> sorted(_, key=lambda x: x.sort_key())\n",
      " |      [x**(-2), 1/x, x**(1/4), sqrt(x), x, x**(3/2), x**2]\n",
      " |  \n",
      " |  taylor_term(self, n, x, *previous_terms)\n",
      " |      General method for the taylor term.\n",
      " |      \n",
      " |      This method is slow, because it differentiates n-times. Subclasses can\n",
      " |      redefine it to make it faster by using the \"previous_terms\".\n",
      " |  \n",
      " |  together(self, *args, **kwargs)\n",
      " |      See the together function in sympy.polys\n",
      " |  \n",
      " |  transpose(self)\n",
      " |  \n",
      " |  trigsimp(self, **args)\n",
      " |      See the trigsimp function in sympy.simplify\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.expr.Expr:\n",
      " |  \n",
      " |  expr_free_symbols\n",
      " |      Like ``free_symbols``, but returns the free symbols only if\n",
      " |      they are contained in an expression node.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (x + y).expr_free_symbols # doctest: +SKIP\n",
      " |      {x, y}\n",
      " |      \n",
      " |      If the expression is contained in a non-expression object, do not return\n",
      " |      the free symbols. Compare:\n",
      " |      \n",
      " |      >>> from sympy import Tuple\n",
      " |      >>> t = Tuple(x + y)\n",
      " |      >>> t.expr_free_symbols # doctest: +SKIP\n",
      " |      set()\n",
      " |      >>> t.free_symbols\n",
      " |      {x, y}\n",
      " |  \n",
      " |  is_number\n",
      " |      Returns True if ``self`` has no free symbols and no\n",
      " |      undefined functions (AppliedUndef, to be precise). It will be\n",
      " |      faster than ``if not self.free_symbols``, however, since\n",
      " |      ``is_number`` will fail as soon as it hits a free symbol\n",
      " |      or undefined function.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Function, Integral, cos, sin, pi\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> f = Function('f')\n",
      " |      \n",
      " |      >>> x.is_number\n",
      " |      False\n",
      " |      >>> f(1).is_number\n",
      " |      False\n",
      " |      >>> (2*x).is_number\n",
      " |      False\n",
      " |      >>> (2 + Integral(2, x)).is_number\n",
      " |      False\n",
      " |      >>> (2 + Integral(2, (x, 1, 2))).is_number\n",
      " |      True\n",
      " |      \n",
      " |      Not all numbers are Numbers in the SymPy sense:\n",
      " |      \n",
      " |      >>> pi.is_number, pi.is_Number\n",
      " |      (True, False)\n",
      " |      \n",
      " |      If something is a number it should evaluate to a number with\n",
      " |      real and imaginary parts that are Numbers; the result may not\n",
      " |      be comparable, however, since the real and/or imaginary part\n",
      " |      of the result may not have precision.\n",
      " |      \n",
      " |      >>> cos(1).is_number and cos(1).is_comparable\n",
      " |      True\n",
      " |      \n",
      " |      >>> z = cos(1)**2 + sin(1)**2 - 1\n",
      " |      >>> z.is_number\n",
      " |      True\n",
      " |      >>> z.is_comparable\n",
      " |      False\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.core.basic.Basic.is_comparable\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.expr.Expr:\n",
      " |  \n",
      " |  is_scalar = True\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __eq__(self, other)\n",
      " |      Return a boolean indicating whether a == b on the basis of\n",
      " |      their symbolic trees.\n",
      " |      \n",
      " |      This is the same as a.compare(b) == 0 but faster.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      If a class that overrides __eq__() needs to retain the\n",
      " |      implementation of __hash__() from a parent class, the\n",
      " |      interpreter must be told this explicitly by setting\n",
      " |      __hash__ : Callable[[object], int] = <ParentClass>.__hash__.\n",
      " |      Otherwise the inheritance of __hash__() will be blocked,\n",
      " |      just as if __hash__ had been explicitly set to None.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      from http://docs.python.org/dev/reference/datamodel.html#object.__hash__\n",
      " |  \n",
      " |  __getnewargs__(self)\n",
      " |  \n",
      " |  __getstate__(self)\n",
      " |  \n",
      " |  __hash__(self) -> int\n",
      " |      Return hash(self).\n",
      " |  \n",
      " |  __ne__(self, other)\n",
      " |      ``a != b``  -> Compare two symbolic trees and see whether they are different\n",
      " |      \n",
      " |      this is the same as:\n",
      " |      \n",
      " |      ``a.compare(b) != 0``\n",
      " |      \n",
      " |      but faster\n",
      " |  \n",
      " |  __reduce_ex__(self, protocol)\n",
      " |      Helper for pickle.\n",
      " |  \n",
      " |  __setstate__(self, state)\n",
      " |  \n",
      " |  as_dummy(self)\n",
      " |      Return the expression with any objects having structurally\n",
      " |      bound symbols replaced with unique, canonical symbols within\n",
      " |      the object in which they appear and having only the default\n",
      " |      assumption for commutativity being True. When applied to a\n",
      " |      symbol a new symbol having only the same commutativity will be\n",
      " |      returned.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> r = Symbol('r', real=True)\n",
      " |      >>> Integral(r, (r, x)).as_dummy()\n",
      " |      Integral(_0, (_0, x))\n",
      " |      >>> _.variables[0].is_real is None\n",
      " |      True\n",
      " |      >>> r.as_dummy()\n",
      " |      _r\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Any object that has structurally bound variables should have\n",
      " |      a property, `bound_symbols` that returns those symbols\n",
      " |      appearing in the object.\n",
      " |  \n",
      " |  atoms(self, *types)\n",
      " |      Returns the atoms that form the current object.\n",
      " |      \n",
      " |      By default, only objects that are truly atomic and cannot\n",
      " |      be divided into smaller pieces are returned: symbols, numbers,\n",
      " |      and number symbols like I and pi. It is possible to request\n",
      " |      atoms of any type, however, as demonstrated below.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import I, pi, sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms()\n",
      " |      {1, 2, I, pi, x, y}\n",
      " |      \n",
      " |      If one or more types are given, the results will contain only\n",
      " |      those types of atoms.\n",
      " |      \n",
      " |      >>> from sympy import Number, NumberSymbol, Symbol\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Symbol)\n",
      " |      {x, y}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number)\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol)\n",
      " |      {1, 2, pi}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol, I)\n",
      " |      {1, 2, I, pi}\n",
      " |      \n",
      " |      Note that I (imaginary unit) and zoo (complex infinity) are special\n",
      " |      types of number symbols and are not part of the NumberSymbol class.\n",
      " |      \n",
      " |      The type can be given implicitly, too:\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(x) # x is a Symbol\n",
      " |      {x, y}\n",
      " |      \n",
      " |      Be careful to check your assumptions when using the implicit option\n",
      " |      since ``S(1).is_Integer = True`` but ``type(S(1))`` is ``One``, a special type\n",
      " |      of SymPy atom, while ``type(S(2))`` is type ``Integer`` and will find all\n",
      " |      integers in an expression:\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(1))\n",
      " |      {1}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(2))\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      Finally, arguments to atoms() can select more than atomic atoms: any\n",
      " |      SymPy type (loaded in core/__init__.py) can be listed as an argument\n",
      " |      and those types of \"atoms\" as found in scanning the arguments of the\n",
      " |      expression recursively:\n",
      " |      \n",
      " |      >>> from sympy import Function, Mul\n",
      " |      >>> from sympy.core.function import AppliedUndef\n",
      " |      >>> f = Function('f')\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(Function)\n",
      " |      {f(x), sin(y + I*pi)}\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(AppliedUndef)\n",
      " |      {f(x)}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Mul)\n",
      " |      {I*pi, 2*sin(y + I*pi)}\n",
      " |  \n",
      " |  compare(self, other)\n",
      " |      Return -1, 0, 1 if the object is smaller, equal, or greater than other.\n",
      " |      \n",
      " |      Not in the mathematical sense. If the object is of a different type\n",
      " |      from the \"other\" then their classes are ordered according to\n",
      " |      the sorted_classes list.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> x.compare(y)\n",
      " |      -1\n",
      " |      >>> x.compare(x)\n",
      " |      0\n",
      " |      >>> y.compare(x)\n",
      " |      1\n",
      " |  \n",
      " |  copy(self)\n",
      " |  \n",
      " |  count(self, query)\n",
      " |      Count the number of matching subexpressions.\n",
      " |  \n",
      " |  dummy_eq(self, other, symbol=None)\n",
      " |      Compare two expressions and handle dummy symbols.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Dummy\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> u = Dummy('u')\n",
      " |      \n",
      " |      >>> (u**2 + 1).dummy_eq(x**2 + 1)\n",
      " |      True\n",
      " |      >>> (u**2 + 1) == (x**2 + 1)\n",
      " |      False\n",
      " |      \n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, x)\n",
      " |      True\n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, y)\n",
      " |      False\n",
      " |  \n",
      " |  find(self, query, group=False)\n",
      " |      Find all subexpressions matching a query.\n",
      " |  \n",
      " |  has(self, *patterns)\n",
      " |      Test whether any subexpression matches any of the patterns.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x**2 + sin(x*y)).has(z)\n",
      " |      False\n",
      " |      >>> (x**2 + sin(x*y)).has(x, y, z)\n",
      " |      True\n",
      " |      >>> x.has(x)\n",
      " |      True\n",
      " |      \n",
      " |      Note ``has`` is a structural algorithm with no knowledge of\n",
      " |      mathematics. Consider the following half-open interval:\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> i = Interval.Lopen(0, 5); i\n",
      " |      Interval.Lopen(0, 5)\n",
      " |      >>> i.args\n",
      " |      (0, 5, True, False)\n",
      " |      >>> i.has(4)  # there is no \"4\" in the arguments\n",
      " |      False\n",
      " |      >>> i.has(0)  # there *is* a \"0\" in the arguments\n",
      " |      True\n",
      " |      \n",
      " |      Instead, use ``contains`` to determine whether a number is in the\n",
      " |      interval or not:\n",
      " |      \n",
      " |      >>> i.contains(4)\n",
      " |      True\n",
      " |      >>> i.contains(0)\n",
      " |      False\n",
      " |      \n",
      " |      \n",
      " |      Note that ``expr.has(*patterns)`` is exactly equivalent to\n",
      " |      ``any(expr.has(p) for p in patterns)``. In particular, ``False`` is\n",
      " |      returned when the list of patterns is empty.\n",
      " |      \n",
      " |      >>> x.has()\n",
      " |      False\n",
      " |  \n",
      " |  has_free(self, *patterns)\n",
      " |      return True if self has object(s) ``x`` as a free expression\n",
      " |      else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Function\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = Function('f')\n",
      " |      >>> g = Function('g')\n",
      " |      >>> expr = Integral(f(x), (f(x), 1, g(y)))\n",
      " |      >>> expr.free_symbols\n",
      " |      {y}\n",
      " |      >>> expr.has_free(g(y))\n",
      " |      True\n",
      " |      >>> expr.has_free(*(x, f(x)))\n",
      " |      False\n",
      " |      \n",
      " |      This works for subexpressions and types, too:\n",
      " |      \n",
      " |      >>> expr.has_free(g)\n",
      " |      True\n",
      " |      >>> (x + y + 1).has_free(y + 1)\n",
      " |      True\n",
      " |  \n",
      " |  is_hypergeometric(self, k)\n",
      " |  \n",
      " |  match(self, pattern, old=False)\n",
      " |      Pattern matching.\n",
      " |      \n",
      " |      Wild symbols match all.\n",
      " |      \n",
      " |      Return ``None`` when expression (self) does not match\n",
      " |      with pattern. Otherwise return a dictionary such that::\n",
      " |      \n",
      " |        pattern.xreplace(self.match(pattern)) == self\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Wild, Sum\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> p = Wild(\"p\")\n",
      " |      >>> q = Wild(\"q\")\n",
      " |      >>> r = Wild(\"r\")\n",
      " |      >>> e = (x+y)**(x+y)\n",
      " |      >>> e.match(p**p)\n",
      " |      {p_: x + y}\n",
      " |      >>> e.match(p**q)\n",
      " |      {p_: x + y, q_: x + y}\n",
      " |      >>> e = (2*x)**2\n",
      " |      >>> e.match(p*q**r)\n",
      " |      {p_: 4, q_: x, r_: 2}\n",
      " |      >>> (p*q**r).xreplace(e.match(p*q**r))\n",
      " |      4*x**2\n",
      " |      \n",
      " |      Structurally bound symbols are ignored during matching:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(y, (y, 1, p)))\n",
      " |      {p_: 2}\n",
      " |      \n",
      " |      But they can be identified if desired:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(q, (q, 1, p)))\n",
      " |      {p_: 2, q_: x}\n",
      " |      \n",
      " |      The ``old`` flag will give the old-style pattern matching where\n",
      " |      expressions and patterns are essentially solved to give the\n",
      " |      match. Both of the following give None unless ``old=True``:\n",
      " |      \n",
      " |      >>> (x - 2).match(p - x, old=True)\n",
      " |      {p_: 2*x - 2}\n",
      " |      >>> (2/x).match(p*x, old=True)\n",
      " |      {p_: 2/x**2}\n",
      " |  \n",
      " |  matches(self, expr, repl_dict=None, old=False)\n",
      " |      Helper method for match() that looks for a match between Wild symbols\n",
      " |      in self and expressions in expr.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, Wild, Basic\n",
      " |      >>> a, b, c = symbols('a b c')\n",
      " |      >>> x = Wild('x')\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b, c)) is None\n",
      " |      True\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b + c, b + c))\n",
      " |      {x_: b + c}\n",
      " |  \n",
      " |  rcall(self, *args)\n",
      " |      Apply on the argument recursively through the expression tree.\n",
      " |      \n",
      " |      This method is used to simulate a common abuse of notation for\n",
      " |      operators. For instance, in SymPy the following will not work:\n",
      " |      \n",
      " |      ``(x+Lambda(y, 2*y))(z) == x+2*z``,\n",
      " |      \n",
      " |      however, you can use:\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x + Lambda(y, 2*y)).rcall(z)\n",
      " |      x + 2*z\n",
      " |  \n",
      " |  refine(self, assumption=True)\n",
      " |      See the refine function in sympy.assumptions\n",
      " |  \n",
      " |  replace(self, query, value, map=False, simultaneous=True, exact=None)\n",
      " |      Replace matching subexpressions of ``self`` with ``value``.\n",
      " |      \n",
      " |      If ``map = True`` then also return the mapping {old: new} where ``old``\n",
      " |      was a sub-expression found with query and ``new`` is the replacement\n",
      " |      value for it. If the expression itself doesn't match the query, then\n",
      " |      the returned value will be ``self.xreplace(map)`` otherwise it should\n",
      " |      be ``self.subs(ordered(map.items()))``.\n",
      " |      \n",
      " |      Traverses an expression tree and performs replacement of matching\n",
      " |      subexpressions from the bottom to the top of the tree. The default\n",
      " |      approach is to do the replacement in a simultaneous fashion so\n",
      " |      changes made are targeted only once. If this is not desired or causes\n",
      " |      problems, ``simultaneous`` can be set to False.\n",
      " |      \n",
      " |      In addition, if an expression containing more than one Wild symbol\n",
      " |      is being used to match subexpressions and the ``exact`` flag is None\n",
      " |      it will be set to True so the match will only succeed if all non-zero\n",
      " |      values are received for each Wild that appears in the match pattern.\n",
      " |      Setting this to False accepts a match of 0; while setting it True\n",
      " |      accepts all matches that have a 0 in them. See example below for\n",
      " |      cautions.\n",
      " |      \n",
      " |      The list of possible combinations of queries and replacement values\n",
      " |      is listed below:\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      Initial setup\n",
      " |      \n",
      " |      >>> from sympy import log, sin, cos, tan, Wild, Mul, Add\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = log(sin(x)) + tan(sin(x**2))\n",
      " |      \n",
      " |      1.1. type -> type\n",
      " |          obj.replace(type, newtype)\n",
      " |      \n",
      " |          When object of type ``type`` is found, replace it with the\n",
      " |          result of passing its argument(s) to ``newtype``.\n",
      " |      \n",
      " |          >>> f.replace(sin, cos)\n",
      " |          log(cos(x)) + tan(cos(x**2))\n",
      " |          >>> sin(x).replace(sin, cos, map=True)\n",
      " |          (cos(x), {sin(x): cos(x)})\n",
      " |          >>> (x*y).replace(Mul, Add)\n",
      " |          x + y\n",
      " |      \n",
      " |      1.2. type -> func\n",
      " |          obj.replace(type, func)\n",
      " |      \n",
      " |          When object of type ``type`` is found, apply ``func`` to its\n",
      " |          argument(s). ``func`` must be written to handle the number\n",
      " |          of arguments of ``type``.\n",
      " |      \n",
      " |          >>> f.replace(sin, lambda arg: sin(2*arg))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |          >>> (x*y).replace(Mul, lambda *args: sin(2*Mul(*args)))\n",
      " |          sin(2*x*y)\n",
      " |      \n",
      " |      2.1. pattern -> expr\n",
      " |          obj.replace(pattern(wild), expr(wild))\n",
      " |      \n",
      " |          Replace subexpressions matching ``pattern`` with the expression\n",
      " |          written in terms of the Wild symbols in ``pattern``.\n",
      " |      \n",
      " |          >>> a, b = map(Wild, 'ab')\n",
      " |          >>> f.replace(sin(a), tan(a))\n",
      " |          log(tan(x)) + tan(tan(x**2))\n",
      " |          >>> f.replace(sin(a), tan(a/2))\n",
      " |          log(tan(x/2)) + tan(tan(x**2/2))\n",
      " |          >>> f.replace(sin(a), a)\n",
      " |          log(x) + tan(x**2)\n",
      " |          >>> (x*y).replace(a*x, a)\n",
      " |          y\n",
      " |      \n",
      " |          Matching is exact by default when more than one Wild symbol\n",
      " |          is used: matching fails unless the match gives non-zero\n",
      " |          values for all Wild symbols:\n",
      " |      \n",
      " |          >>> (2*x + y).replace(a*x + b, b - a)\n",
      " |          y - 2\n",
      " |          >>> (2*x).replace(a*x + b, b - a)\n",
      " |          2*x\n",
      " |      \n",
      " |          When set to False, the results may be non-intuitive:\n",
      " |      \n",
      " |          >>> (2*x).replace(a*x + b, b - a, exact=False)\n",
      " |          2/x\n",
      " |      \n",
      " |      2.2. pattern -> func\n",
      " |          obj.replace(pattern(wild), lambda wild: expr(wild))\n",
      " |      \n",
      " |          All behavior is the same as in 2.1 but now a function in terms of\n",
      " |          pattern variables is used rather than an expression:\n",
      " |      \n",
      " |          >>> f.replace(sin(a), lambda a: sin(2*a))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |      \n",
      " |      3.1. func -> func\n",
      " |          obj.replace(filter, func)\n",
      " |      \n",
      " |          Replace subexpression ``e`` with ``func(e)`` if ``filter(e)``\n",
      " |          is True.\n",
      " |      \n",
      " |          >>> g = 2*sin(x**3)\n",
      " |          >>> g.replace(lambda expr: expr.is_Number, lambda expr: expr**2)\n",
      " |          4*sin(x**9)\n",
      " |      \n",
      " |      The expression itself is also targeted by the query but is done in\n",
      " |      such a fashion that changes are not made twice.\n",
      " |      \n",
      " |          >>> e = x*(x*y + 1)\n",
      " |          >>> e.replace(lambda x: x.is_Mul, lambda x: 2*x)\n",
      " |          2*x*(2*x*y + 1)\n",
      " |      \n",
      " |      When matching a single symbol, `exact` will default to True, but\n",
      " |      this may or may not be the behavior that is desired:\n",
      " |      \n",
      " |      Here, we want `exact=False`:\n",
      " |      \n",
      " |      >>> from sympy import Function\n",
      " |      >>> f = Function('f')\n",
      " |      >>> e = f(1) + f(0)\n",
      " |      >>> q = f(a), lambda a: f(a + 1)\n",
      " |      >>> e.replace(*q, exact=False)\n",
      " |      f(1) + f(2)\n",
      " |      >>> e.replace(*q, exact=True)\n",
      " |      f(0) + f(2)\n",
      " |      \n",
      " |      But here, the nature of matching makes selecting\n",
      " |      the right setting tricky:\n",
      " |      \n",
      " |      >>> e = x**(1 + y)\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(-x - y + 1)\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(1 - y)\n",
      " |      \n",
      " |      It is probably better to use a different form of the query\n",
      " |      that describes the target expression more precisely:\n",
      " |      \n",
      " |      >>> (1 + x**(1 + y)).replace(\n",
      " |      ... lambda x: x.is_Pow and x.exp.is_Add and x.exp.args[0] == 1,\n",
      " |      ... lambda x: x.base**(1 - (x.exp - 1)))\n",
      " |      ...\n",
      " |      x**(1 - y) + 1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      subs: substitution of subexpressions as defined by the objects\n",
      " |            themselves.\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |  \n",
      " |  rewrite(self, *args, deep=True, **hints)\n",
      " |      Rewrite *self* using a defined rule.\n",
      " |      \n",
      " |      Rewriting transforms an expression to another, which is mathematically\n",
      " |      equivalent but structurally different. For example you can rewrite\n",
      " |      trigonometric functions as complex exponentials or combinatorial\n",
      " |      functions as gamma function.\n",
      " |      \n",
      " |      This method takes a *pattern* and a *rule* as positional arguments.\n",
      " |      *pattern* is optional parameter which defines the types of expressions\n",
      " |      that will be transformed. If it is not passed, all possible expressions\n",
      " |      will be rewritten. *rule* defines how the expression will be rewritten.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      args : *rule*, or *pattern* and *rule*.\n",
      " |          - *pattern* is a type or an iterable of types.\n",
      " |          - *rule* can be any object.\n",
      " |      \n",
      " |      deep : bool, optional.\n",
      " |          If ``True``, subexpressions are recursively transformed. Default is\n",
      " |          ``True``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      If *pattern* is unspecified, all possible expressions are transformed.\n",
      " |      \n",
      " |      >>> from sympy import cos, sin, exp, I\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> expr = cos(x) + I*sin(x)\n",
      " |      >>> expr.rewrite(exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Pattern can be a type or an iterable of types.\n",
      " |      \n",
      " |      >>> expr.rewrite(sin, exp)\n",
      " |      exp(I*x)/2 + cos(x) - exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos,], exp)\n",
      " |      exp(I*x)/2 + I*sin(x) + exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos, sin], exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Rewriting behavior can be implemented by defining ``_eval_rewrite()``\n",
      " |      method.\n",
      " |      \n",
      " |      >>> from sympy import Expr, sqrt, pi\n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite(self, rule, args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         if rule == cos:\n",
      " |      ...             return cos(pi/2 - x, evaluate=False)\n",
      " |      ...         if rule == sqrt:\n",
      " |      ...             return sqrt(1 - cos(x)**2)\n",
      " |      >>> MySin(MySin(x)).rewrite(cos)\n",
      " |      cos(-cos(-x + pi/2) + pi/2)\n",
      " |      >>> MySin(x).rewrite(sqrt)\n",
      " |      sqrt(1 - cos(x)**2)\n",
      " |      \n",
      " |      Defining ``_eval_rewrite_as_[...]()`` method is supported for backwards\n",
      " |      compatibility reason. This may be removed in the future and using it is\n",
      " |      discouraged.\n",
      " |      \n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite_as_cos(self, *args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         return cos(pi/2 - x, evaluate=False)\n",
      " |      >>> MySin(x).rewrite(cos)\n",
      " |      cos(-x + pi/2)\n",
      " |  \n",
      " |  simplify(self, **kwargs)\n",
      " |      See the simplify function in sympy.simplify\n",
      " |  \n",
      " |  subs(self, *args, **kwargs)\n",
      " |      Substitutes old for new in an expression after sympifying args.\n",
      " |      \n",
      " |      `args` is either:\n",
      " |        - two arguments, e.g. foo.subs(old, new)\n",
      " |        - one iterable argument, e.g. foo.subs(iterable). The iterable may be\n",
      " |           o an iterable container with (old, new) pairs. In this case the\n",
      " |             replacements are processed in the order given with successive\n",
      " |             patterns possibly affecting replacements already made.\n",
      " |           o a dict or set whose key/value items correspond to old/new pairs.\n",
      " |             In this case the old/new pairs will be sorted by op count and in\n",
      " |             case of a tie, by number of args and the default_sort_key. The\n",
      " |             resulting sorted list is then processed as an iterable container\n",
      " |             (see previous).\n",
      " |      \n",
      " |      If the keyword ``simultaneous`` is True, the subexpressions will not be\n",
      " |      evaluated until all the substitutions have been made.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import pi, exp, limit, oo\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x*y).subs(x, pi)\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).subs({x:pi, y:2})\n",
      " |      1 + 2*pi\n",
      " |      >>> (1 + x*y).subs([(x, pi), (y, 2)])\n",
      " |      1 + 2*pi\n",
      " |      >>> reps = [(y, x**2), (x, 2)]\n",
      " |      >>> (x + y).subs(reps)\n",
      " |      6\n",
      " |      >>> (x + y).subs(reversed(reps))\n",
      " |      x**2 + 2\n",
      " |      \n",
      " |      >>> (x**2 + x**4).subs(x**2, y)\n",
      " |      y**2 + y\n",
      " |      \n",
      " |      To replace only the x**2 but not the x**4, use xreplace:\n",
      " |      \n",
      " |      >>> (x**2 + x**4).xreplace({x**2: y})\n",
      " |      x**4 + y\n",
      " |      \n",
      " |      To delay evaluation until all substitutions have been made,\n",
      " |      set the keyword ``simultaneous`` to True:\n",
      " |      \n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)])\n",
      " |      0\n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)], simultaneous=True)\n",
      " |      nan\n",
      " |      \n",
      " |      This has the added feature of not allowing subsequent substitutions\n",
      " |      to affect those already made:\n",
      " |      \n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y})\n",
      " |      1\n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y}, simultaneous=True)\n",
      " |      y/(x + y)\n",
      " |      \n",
      " |      In order to obtain a canonical result, unordered iterables are\n",
      " |      sorted by count_op length, number of arguments and by the\n",
      " |      default_sort_key to break any ties. All other iterables are left\n",
      " |      unsorted.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, sin, cos\n",
      " |      >>> from sympy.abc import a, b, c, d, e\n",
      " |      \n",
      " |      >>> A = (sqrt(sin(2*x)), a)\n",
      " |      >>> B = (sin(2*x), b)\n",
      " |      >>> C = (cos(2*x), c)\n",
      " |      >>> D = (x, d)\n",
      " |      >>> E = (exp(x), e)\n",
      " |      \n",
      " |      >>> expr = sqrt(sin(2*x))*sin(exp(x)*x)*cos(2*x) + sin(2*x)\n",
      " |      \n",
      " |      >>> expr.subs(dict([A, B, C, D, E]))\n",
      " |      a*c*sin(d*e) + b\n",
      " |      \n",
      " |      The resulting expression represents a literal replacement of the\n",
      " |      old arguments with the new arguments. This may not reflect the\n",
      " |      limiting behavior of the expression:\n",
      " |      \n",
      " |      >>> (x**3 - 3*x).subs({x: oo})\n",
      " |      nan\n",
      " |      \n",
      " |      >>> limit(x**3 - 3*x, x, oo)\n",
      " |      oo\n",
      " |      \n",
      " |      If the substitution will be followed by numerical\n",
      " |      evaluation, it is better to pass the substitution to\n",
      " |      evalf as\n",
      " |      \n",
      " |      >>> (1/x).evalf(subs={x: 3.0}, n=21)\n",
      " |      0.333333333333333333333\n",
      " |      \n",
      " |      rather than\n",
      " |      \n",
      " |      >>> (1/x).subs({x: 3.0}).evalf(21)\n",
      " |      0.333333333333333314830\n",
      " |      \n",
      " |      as the former will ensure that the desired level of precision is\n",
      " |      obtained.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |      sympy.core.evalf.EvalfMixin.evalf: calculates the given formula to a desired level of precision\n",
      " |  \n",
      " |  xreplace lambda rule, **_\n",
      " |      # Function needs args so we define a property that returns\n",
      " |      # a function that takes args...and then use that function\n",
      " |      # to return the right value\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  fromiter(args, **assumptions) from sympy.core.function.FunctionClass\n",
      " |      Create a new object from an iterable.\n",
      " |      \n",
      " |      This is a convenience function that allows one to create objects from\n",
      " |      any iterable, without having to convert to a list or tuple first.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Tuple\n",
      " |      >>> Tuple.fromiter(i for i in range(5))\n",
      " |      (0, 1, 2, 3, 4)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  args\n",
      " |      Returns a tuple of arguments of 'self'.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cot\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> cot(x).args\n",
      " |      (x,)\n",
      " |      \n",
      " |      >>> cot(x).args[0]\n",
      " |      x\n",
      " |      \n",
      " |      >>> (x*y).args\n",
      " |      (x, y)\n",
      " |      \n",
      " |      >>> (x*y).args[1]\n",
      " |      y\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Never use self._args, always use self.args.\n",
      " |      Only use _args in __new__ when creating a new function.\n",
      " |      Don't override .args() from Basic (so that it's easy to\n",
      " |      change the interface in the future if needed).\n",
      " |  \n",
      " |  assumptions0\n",
      " |      Return object `type` assumptions.\n",
      " |      \n",
      " |      For example:\n",
      " |      \n",
      " |        Symbol('x', real=True)\n",
      " |        Symbol('x', integer=True)\n",
      " |      \n",
      " |      are different objects. In other words, besides Python type (Symbol in\n",
      " |      this case), the initial assumptions are also forming their typeinfo.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True}\n",
      " |      >>> x = Symbol(\"x\", positive=True)\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True, 'complex': True, 'extended_negative': False,\n",
      " |       'extended_nonnegative': True, 'extended_nonpositive': False,\n",
      " |       'extended_nonzero': True, 'extended_positive': True, 'extended_real':\n",
      " |       True, 'finite': True, 'hermitian': True, 'imaginary': False,\n",
      " |       'infinite': False, 'negative': False, 'nonnegative': True,\n",
      " |       'nonpositive': False, 'nonzero': True, 'positive': True, 'real':\n",
      " |       True, 'zero': False}\n",
      " |  \n",
      " |  canonical_variables\n",
      " |      Return a dictionary mapping any variable defined in\n",
      " |      ``self.bound_symbols`` to Symbols that do not clash\n",
      " |      with any free symbols in the expression.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> Lambda(x, 2*x).canonical_variables\n",
      " |      {x: _0}\n",
      " |  \n",
      " |  free_symbols\n",
      " |      Return from the atoms of self those which are free symbols.\n",
      " |      \n",
      " |      For most expressions, all symbols are free symbols. For some classes\n",
      " |      this is not true. e.g. Integrals use Symbols for the dummy variables\n",
      " |      which are bound variables, so Integral has a method to return all\n",
      " |      symbols except those. Derivative keeps track of symbols with respect\n",
      " |      to which it will perform a derivative; those are\n",
      " |      bound variables, too, so it has its own free_symbols method.\n",
      " |      \n",
      " |      Any other method that uses bound variables should implement a\n",
      " |      free_symbols method.\n",
      " |  \n",
      " |  is_algebraic\n",
      " |  \n",
      " |  is_antihermitian\n",
      " |  \n",
      " |  is_commutative\n",
      " |  \n",
      " |  is_comparable\n",
      " |      Return True if self can be computed to a real number\n",
      " |      (or already is a real number) with precision, else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import exp_polar, pi, I\n",
      " |      >>> (I*exp_polar(I*pi/2)).is_comparable\n",
      " |      True\n",
      " |      >>> (I*exp_polar(I*pi*2)).is_comparable\n",
      " |      False\n",
      " |      \n",
      " |      A False result does not mean that `self` cannot be rewritten\n",
      " |      into a form that would be comparable. For example, the\n",
      " |      difference computed below is zero but without simplification\n",
      " |      it does not evaluate to a zero with precision:\n",
      " |      \n",
      " |      >>> e = 2**pi*(1 + 2**pi)\n",
      " |      >>> dif = e - e.expand()\n",
      " |      >>> dif.is_comparable\n",
      " |      False\n",
      " |      >>> dif.n(2)._prec\n",
      " |      1\n",
      " |  \n",
      " |  is_complex\n",
      " |  \n",
      " |  is_composite\n",
      " |  \n",
      " |  is_even\n",
      " |  \n",
      " |  is_extended_negative\n",
      " |  \n",
      " |  is_extended_nonnegative\n",
      " |  \n",
      " |  is_extended_nonpositive\n",
      " |  \n",
      " |  is_extended_nonzero\n",
      " |  \n",
      " |  is_extended_positive\n",
      " |  \n",
      " |  is_extended_real\n",
      " |  \n",
      " |  is_finite\n",
      " |  \n",
      " |  is_hermitian\n",
      " |  \n",
      " |  is_imaginary\n",
      " |  \n",
      " |  is_infinite\n",
      " |  \n",
      " |  is_integer\n",
      " |  \n",
      " |  is_irrational\n",
      " |  \n",
      " |  is_negative\n",
      " |  \n",
      " |  is_noninteger\n",
      " |  \n",
      " |  is_nonnegative\n",
      " |  \n",
      " |  is_nonpositive\n",
      " |  \n",
      " |  is_nonzero\n",
      " |  \n",
      " |  is_odd\n",
      " |  \n",
      " |  is_polar\n",
      " |  \n",
      " |  is_positive\n",
      " |  \n",
      " |  is_prime\n",
      " |  \n",
      " |  is_rational\n",
      " |  \n",
      " |  is_real\n",
      " |  \n",
      " |  is_transcendental\n",
      " |  \n",
      " |  is_zero\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __annotations__ = {'_args': 'Tuple[Basic, ...]', '_mhash': 'Any', 'kin...\n",
      " |  \n",
      " |  is_Add = False\n",
      " |  \n",
      " |  is_AlgebraicNumber = False\n",
      " |  \n",
      " |  is_Atom = False\n",
      " |  \n",
      " |  is_Boolean = False\n",
      " |  \n",
      " |  is_Derivative = False\n",
      " |  \n",
      " |  is_Dummy = False\n",
      " |  \n",
      " |  is_Equality = False\n",
      " |  \n",
      " |  is_Float = False\n",
      " |  \n",
      " |  is_Indexed = False\n",
      " |  \n",
      " |  is_Integer = False\n",
      " |  \n",
      " |  is_MatAdd = False\n",
      " |  \n",
      " |  is_MatMul = False\n",
      " |  \n",
      " |  is_Matrix = False\n",
      " |  \n",
      " |  is_Mul = False\n",
      " |  \n",
      " |  is_Not = False\n",
      " |  \n",
      " |  is_Number = False\n",
      " |  \n",
      " |  is_NumberSymbol = False\n",
      " |  \n",
      " |  is_Order = False\n",
      " |  \n",
      " |  is_Point = False\n",
      " |  \n",
      " |  is_Poly = False\n",
      " |  \n",
      " |  is_Pow = False\n",
      " |  \n",
      " |  is_Rational = False\n",
      " |  \n",
      " |  is_Relational = False\n",
      " |  \n",
      " |  is_Symbol = False\n",
      " |  \n",
      " |  is_Vector = False\n",
      " |  \n",
      " |  is_Wild = False\n",
      " |  \n",
      " |  is_symbol = False\n",
      " |  \n",
      " |  kind = UndefinedKind\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.printing.defaults.Printable:\n",
      " |  \n",
      " |  __repr__ = __str__(self)\n",
      " |  \n",
      " |  __str__(self)\n",
      " |      Return str(self).\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.evalf.EvalfMixin:\n",
      " |  \n",
      " |  evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      " |      Evaluate the given formula to an accuracy of *n* digits.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      subs : dict, optional\n",
      " |          Substitute numerical values for symbols, e.g.\n",
      " |          ``subs={x:3, y:1+pi}``. The substitutions must be given as a\n",
      " |          dictionary.\n",
      " |      \n",
      " |      maxn : int, optional\n",
      " |          Allow a maximum temporary working precision of maxn digits.\n",
      " |      \n",
      " |      chop : bool or number, optional\n",
      " |          Specifies how to replace tiny real or imaginary parts in\n",
      " |          subresults by exact zeros.\n",
      " |      \n",
      " |          When ``True`` the chop value defaults to standard precision.\n",
      " |      \n",
      " |          Otherwise the chop value is used to determine the\n",
      " |          magnitude of \"small\" for purposes of chopping.\n",
      " |      \n",
      " |          >>> from sympy import N\n",
      " |          >>> x = 1e-4\n",
      " |          >>> N(x, chop=True)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-5)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-4)\n",
      " |          0\n",
      " |      \n",
      " |      strict : bool, optional\n",
      " |          Raise ``PrecisionExhausted`` if any subresult fails to\n",
      " |          evaluate to full accuracy, given the available maxprec.\n",
      " |      \n",
      " |      quad : str, optional\n",
      " |          Choose algorithm for numerical quadrature. By default,\n",
      " |          tanh-sinh quadrature is used. For oscillatory\n",
      " |          integrals on an infinite interval, try ``quad='osc'``.\n",
      " |      \n",
      " |      verbose : bool, optional\n",
      " |          Print debug information.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      When Floats are naively substituted into an expression,\n",
      " |      precision errors may adversely affect the result. For example,\n",
      " |      adding 1e16 (a Float) to 1 will truncate to 1e16; if 1e16 is\n",
      " |      then subtracted, the result will be 0.\n",
      " |      That is exactly what happens in the following:\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> values = {x: 1e16, y: 1, z: 1e16}\n",
      " |      >>> (x + y - z).subs(values)\n",
      " |      0\n",
      " |      \n",
      " |      Using the subs argument for evalf is the accurate way to\n",
      " |      evaluate such an expression:\n",
      " |      \n",
      " |      >>> (x + y - z).evalf(subs=values)\n",
      " |      1.00000000000000\n",
      " |  \n",
      " |  n = evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(Piecewise)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd400c25",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=Piecewise()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "8e268c79",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[0, 2\\right]$"
      ],
      "text/plain": [
       "Interval(0, 2)"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(abs(x-1)>=(x-1)**2,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "31371851",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left(-\\infty, \\infty\\right)$"
      ],
      "text/plain": [
       "Interval(-oo, oo)"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(-x**2+3*x-4<0,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "4419e09d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{True}$"
      ],
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Eq(solveset(-x**2+3*x-4<0,x,Reals),Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "f4b2caa6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[0, 2\\right)$"
      ],
      "text/plain": [
       "Interval.Ropen(0, 2)"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(x/(x-2)<=0,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "0023b5cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[1, 2\\right]$"
      ],
      "text/plain": [
       "Interval(1, 2)"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(x**2-3*x+2<=0,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "1a25c1a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[1, 2\\right)$"
      ],
      "text/plain": [
       "Interval.Ropen(1, 2)"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(x/(x-2)<=0,x,Reals).intersect(solveset(x**2-3*x+2<=0,x,Reals))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "77445bb7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left(-\\infty, -1\\right) \\cup \\left(2, \\infty\\right)$"
      ],
      "text/plain": [
       "Union(Interval.open(-oo, -1), Interval.open(2, oo))"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset((x+1)/(x-2)>0,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "37807087",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "EmptySet in FiniteSet(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "8cfc03f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{1, 2\\right\\}$"
      ],
      "text/plain": [
       "Range(1, 3, 1)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(x**2-3*x<0,x,Integers)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "5307cdf0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\mathbb{R} \\cap \\left\\{- a, a + 1\\right\\}$"
      ],
      "text/plain": [
       "Intersection({-a, a + 1}, Reals)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(Eq(-x**2+x+a**2+a,0),x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "891f0eae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[- \\frac{1}{2}, 1\\right)$"
      ],
      "text/plain": [
       "Interval.Ropen(-1/2, 1)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_range((x**2-1)/(x**2+2),x,Interval.open(-1,oo))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "de89a43d",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class Piecewise in module sympy.functions.elementary.piecewise:\n",
      "\n",
      "class Piecewise(sympy.core.function.Function)\n",
      " |  Piecewise(*_args)\n",
      " |  \n",
      " |  Represents a piecewise function.\n",
      " |  \n",
      " |  Usage:\n",
      " |  \n",
      " |    Piecewise( (expr,cond), (expr,cond), ... )\n",
      " |      - Each argument is a 2-tuple defining an expression and condition\n",
      " |      - The conds are evaluated in turn returning the first that is True.\n",
      " |        If any of the evaluated conds are not explicitly False,\n",
      " |        e.g. ``x < 1``, the function is returned in symbolic form.\n",
      " |      - If the function is evaluated at a place where all conditions are False,\n",
      " |        nan will be returned.\n",
      " |      - Pairs where the cond is explicitly False, will be removed and no pair\n",
      " |        appearing after a True condition will ever be retained. If a single\n",
      " |        pair with a True condition remains, it will be returned, even when\n",
      " |        evaluation is False.\n",
      " |  \n",
      " |  Examples\n",
      " |  ========\n",
      " |  \n",
      " |  >>> from sympy import Piecewise, log, piecewise_fold\n",
      " |  >>> from sympy.abc import x, y\n",
      " |  >>> f = x**2\n",
      " |  >>> g = log(x)\n",
      " |  >>> p = Piecewise((0, x < -1), (f, x <= 1), (g, True))\n",
      " |  >>> p.subs(x,1)\n",
      " |  1\n",
      " |  >>> p.subs(x,5)\n",
      " |  log(5)\n",
      " |  \n",
      " |  Booleans can contain Piecewise elements:\n",
      " |  \n",
      " |  >>> cond = (x < y).subs(x, Piecewise((2, x < 0), (3, True))); cond\n",
      " |  Piecewise((2, x < 0), (3, True)) < y\n",
      " |  \n",
      " |  The folded version of this results in a Piecewise whose\n",
      " |  expressions are Booleans:\n",
      " |  \n",
      " |  >>> folded_cond = piecewise_fold(cond); folded_cond\n",
      " |  Piecewise((2 < y, x < 0), (3 < y, True))\n",
      " |  \n",
      " |  When a Boolean containing Piecewise (like cond) or a Piecewise\n",
      " |  with Boolean expressions (like folded_cond) is used as a condition,\n",
      " |  it is converted to an equivalent :class:`~.ITE` object:\n",
      " |  \n",
      " |  >>> Piecewise((1, folded_cond))\n",
      " |  Piecewise((1, ITE(x < 0, y > 2, y > 3)))\n",
      " |  \n",
      " |  When a condition is an ``ITE``, it will be converted to a simplified\n",
      " |  Boolean expression:\n",
      " |  \n",
      " |  >>> piecewise_fold(_)\n",
      " |  Piecewise((1, ((x >= 0) | (y > 2)) & ((y > 3) | (x < 0))))\n",
      " |  \n",
      " |  See Also\n",
      " |  ========\n",
      " |  piecewise_fold, ITE\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      Piecewise\n",
      " |      sympy.core.function.Function\n",
      " |      sympy.core.function.Application\n",
      " |      sympy.core.expr.Expr\n",
      " |      sympy.core.basic.Basic\n",
      " |      sympy.printing.defaults.Printable\n",
      " |      sympy.core.evalf.EvalfMixin\n",
      " |      builtins.object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  as_expr_set_pairs(self, domain=None)\n",
      " |      Return tuples for each argument of self that give\n",
      " |      the expression and the interval in which it is valid\n",
      " |      which is contained within the given domain.\n",
      " |      If a condition cannot be converted to a set, an error\n",
      " |      will be raised. The variable of the conditions is\n",
      " |      assumed to be real; sets of real values are returned.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Piecewise, Interval\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> p = Piecewise(\n",
      " |      ...     (1, x < 2),\n",
      " |      ...     (2,(x > 0) & (x < 4)),\n",
      " |      ...     (3, True))\n",
      " |      >>> p.as_expr_set_pairs()\n",
      " |      [(1, Interval.open(-oo, 2)),\n",
      " |       (2, Interval.Ropen(2, 4)),\n",
      " |       (3, Interval(4, oo))]\n",
      " |      >>> p.as_expr_set_pairs(Interval(0, 3))\n",
      " |      [(1, Interval.Ropen(0, 2)),\n",
      " |       (2, Interval(2, 3))]\n",
      " |  \n",
      " |  doit(self, **hints)\n",
      " |      Evaluate this piecewise function.\n",
      " |  \n",
      " |  piecewise_integrate(self, x, **kwargs)\n",
      " |      Return the Piecewise with each expression being\n",
      " |      replaced with its antiderivative. To obtain a continuous\n",
      " |      antiderivative, use the :func:`~.integrate` function or method.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Piecewise\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> p = Piecewise((0, x < 0), (1, x < 1), (2, True))\n",
      " |      >>> p.piecewise_integrate(x)\n",
      " |      Piecewise((0, x < 0), (x, x < 1), (2*x, True))\n",
      " |      \n",
      " |      Note that this does not give a continuous function, e.g.\n",
      " |      at x = 1 the 3rd condition applies and the antiderivative\n",
      " |      there is 2*x so the value of the antiderivative is 2:\n",
      " |      \n",
      " |      >>> anti = _\n",
      " |      >>> anti.subs(x, 1)\n",
      " |      2\n",
      " |      \n",
      " |      The continuous derivative accounts for the integral *up to*\n",
      " |      the point of interest, however:\n",
      " |      \n",
      " |      >>> p.integrate(x)\n",
      " |      Piecewise((0, x < 0), (x, x < 1), (2*x - 1, True))\n",
      " |      >>> _.subs(x, 1)\n",
      " |      1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      Piecewise._eval_integral\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods defined here:\n",
      " |  \n",
      " |  eval(*_args) from sympy.core.function.FunctionClass\n",
      " |      Either return a modified version of the args or, if no\n",
      " |      modifications were made, return None.\n",
      " |      \n",
      " |      Modifications that are made here:\n",
      " |      \n",
      " |      1. relationals are made canonical\n",
      " |      2. any False conditions are dropped\n",
      " |      3. any repeat of a previous condition is ignored\n",
      " |      4. any args past one with a true condition are dropped\n",
      " |      \n",
      " |      If there are no args left, nan will be returned.\n",
      " |      If there is a single arg with a True condition, its\n",
      " |      corresponding expression will be returned.\n",
      " |      \n",
      " |      EXAMPLES\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Piecewise\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> cond = -x < -1\n",
      " |      >>> args = [(1, cond), (4, cond), (3, False), (2, True), (5, x < 1)]\n",
      " |      >>> Piecewise(*args, evaluate=False)\n",
      " |      Piecewise((1, -x < -1), (4, -x < -1), (2, True))\n",
      " |      >>> Piecewise(*args)\n",
      " |      Piecewise((1, x > 1), (2, True))\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  __new__(cls, *args, **options)\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties defined here:\n",
      " |  \n",
      " |  __sympy__\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes defined here:\n",
      " |  \n",
      " |  default_assumptions = {}\n",
      " |  \n",
      " |  is_Piecewise = True\n",
      " |  \n",
      " |  nargs = Naturals0\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.function.Function:\n",
      " |  \n",
      " |  as_base_exp(self)\n",
      " |      Returns the method as the 2-tuple (base, exponent).\n",
      " |  \n",
      " |  fdiff(self, argindex=1)\n",
      " |      Returns the first derivative of the function.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.core.function.Function:\n",
      " |  \n",
      " |  class_key() from sympy.core.function.FunctionClass\n",
      " |      Nice order of classes.\n",
      " |  \n",
      " |  is_singular(a) from sympy.core.function.FunctionClass\n",
      " |      Tests whether the argument is an essential singularity\n",
      " |      or a branch point, or the functions is non-holomorphic.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.function.Application:\n",
      " |  \n",
      " |  func\n",
      " |      The top-level function in an expression.\n",
      " |      \n",
      " |      The following should hold for all objects::\n",
      " |      \n",
      " |          >> x == x.func(*x.args)\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> a = 2*x\n",
      " |      >>> a.func\n",
      " |      <class 'sympy.core.mul.Mul'>\n",
      " |      >>> a.args\n",
      " |      (2, x)\n",
      " |      >>> a.func(*a.args)\n",
      " |      2*x\n",
      " |      >>> a == a.func(*a.args)\n",
      " |      True\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from sympy.core.function.Application:\n",
      " |  \n",
      " |  __dict__\n",
      " |      dictionary for instance variables (if defined)\n",
      " |  \n",
      " |  __weakref__\n",
      " |      list of weak references to the object (if defined)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.function.Application:\n",
      " |  \n",
      " |  is_Function = True\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.expr.Expr:\n",
      " |  \n",
      " |  __abs__(self)\n",
      " |  \n",
      " |  __add__(self, other)\n",
      " |  \n",
      " |  __complex__(self)\n",
      " |  \n",
      " |  __divmod__(self, other)\n",
      " |  \n",
      " |  __float__(self)\n",
      " |  \n",
      " |  __floordiv__(self, other)\n",
      " |  \n",
      " |  __ge__(self, other)\n",
      " |      Return self>=value.\n",
      " |  \n",
      " |  __gt__(self, other)\n",
      " |      Return self>value.\n",
      " |  \n",
      " |  __int__(self)\n",
      " |  \n",
      " |  __le__(self, other)\n",
      " |      Return self<=value.\n",
      " |  \n",
      " |  __lt__(self, other)\n",
      " |      Return self<value.\n",
      " |  \n",
      " |  __mod__(self, other)\n",
      " |  \n",
      " |  __mul__(self, other)\n",
      " |  \n",
      " |  __neg__(self)\n",
      " |  \n",
      " |  __pos__(self)\n",
      " |  \n",
      " |  __pow__(self, other, mod=None)\n",
      " |  \n",
      " |  __radd__(self, other)\n",
      " |  \n",
      " |  __rdivmod__(self, other)\n",
      " |  \n",
      " |  __rfloordiv__(self, other)\n",
      " |  \n",
      " |  __rmod__(self, other)\n",
      " |  \n",
      " |  __rmul__(self, other)\n",
      " |  \n",
      " |  __round__ = round(self, n=None)\n",
      " |  \n",
      " |  __rpow__(self, other)\n",
      " |  \n",
      " |  __rsub__(self, other)\n",
      " |  \n",
      " |  __rtruediv__(self, other)\n",
      " |  \n",
      " |  __sub__(self, other)\n",
      " |  \n",
      " |  __truediv__(self, other)\n",
      " |  \n",
      " |  __trunc__(self)\n",
      " |  \n",
      " |  adjoint(self)\n",
      " |  \n",
      " |  apart(self, x=None, **args)\n",
      " |      See the apart function in sympy.polys\n",
      " |  \n",
      " |  args_cnc(self, cset=False, warn=True, split_1=True)\n",
      " |      Return [commutative factors, non-commutative factors] of self.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      self is treated as a Mul and the ordering of the factors is maintained.\n",
      " |      If ``cset`` is True the commutative factors will be returned in a set.\n",
      " |      If there were repeated factors (as may happen with an unevaluated Mul)\n",
      " |      then an error will be raised unless it is explicitly suppressed by\n",
      " |      setting ``warn`` to False.\n",
      " |      \n",
      " |      Note: -1 is always separated from a Number unless split_1 is False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, oo\n",
      " |      >>> A, B = symbols('A B', commutative=0)\n",
      " |      >>> x, y = symbols('x y')\n",
      " |      >>> (-2*x*y).args_cnc()\n",
      " |      [[-1, 2, x, y], []]\n",
      " |      >>> (-2.5*x).args_cnc()\n",
      " |      [[-1, 2.5, x], []]\n",
      " |      >>> (-2*x*A*B*y).args_cnc()\n",
      " |      [[-1, 2, x, y], [A, B]]\n",
      " |      >>> (-2*x*A*B*y).args_cnc(split_1=False)\n",
      " |      [[-2, x, y], [A, B]]\n",
      " |      >>> (-2*x*y).args_cnc(cset=True)\n",
      " |      [{-1, 2, x, y}, []]\n",
      " |      \n",
      " |      The arg is always treated as a Mul:\n",
      " |      \n",
      " |      >>> (-2 + x + A).args_cnc()\n",
      " |      [[], [x - 2 + A]]\n",
      " |      >>> (-oo).args_cnc() # -oo is a singleton\n",
      " |      [[-1, oo], []]\n",
      " |  \n",
      " |  as_coeff_Add(self, rational=False)\n",
      " |      Efficiently extract the coefficient of a summation.\n",
      " |  \n",
      " |  as_coeff_Mul(self, rational=False)\n",
      " |      Efficiently extract the coefficient of a product.\n",
      " |  \n",
      " |  as_coeff_add(self, *deps)\n",
      " |      Return the tuple (c, args) where self is written as an Add, ``a``.\n",
      " |      \n",
      " |      c should be a Rational added to any terms of the Add that are\n",
      " |      independent of deps.\n",
      " |      \n",
      " |      args should be a tuple of all other terms of ``a``; args is empty\n",
      " |      if self is a Number or if self is independent of deps (when given).\n",
      " |      \n",
      " |      This should be used when you do not know if self is an Add or not but\n",
      " |      you want to treat self as an Add or if you want to process the\n",
      " |      individual arguments of the tail of self as an Add.\n",
      " |      \n",
      " |      - if you know self is an Add and want only the head, use self.args[0];\n",
      " |      - if you do not want to process the arguments of the tail but need the\n",
      " |        tail then use self.as_two_terms() which gives the head and tail.\n",
      " |      - if you want to split self into an independent and dependent parts\n",
      " |        use ``self.as_independent(*deps)``\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (S(3)).as_coeff_add()\n",
      " |      (3, ())\n",
      " |      >>> (3 + x).as_coeff_add()\n",
      " |      (3, (x,))\n",
      " |      >>> (3 + x + y).as_coeff_add(x)\n",
      " |      (y + 3, (x,))\n",
      " |      >>> (3 + y).as_coeff_add(x)\n",
      " |      (y + 3, ())\n",
      " |  \n",
      " |  as_coeff_exponent(self, x)\n",
      " |      ``c*x**e -> c,e`` where x can be any symbolic expression.\n",
      " |  \n",
      " |  as_coeff_mul(self, *deps, **kwargs)\n",
      " |      Return the tuple (c, args) where self is written as a Mul, ``m``.\n",
      " |      \n",
      " |      c should be a Rational multiplied by any factors of the Mul that are\n",
      " |      independent of deps.\n",
      " |      \n",
      " |      args should be a tuple of all other factors of m; args is empty\n",
      " |      if self is a Number or if self is independent of deps (when given).\n",
      " |      \n",
      " |      This should be used when you do not know if self is a Mul or not but\n",
      " |      you want to treat self as a Mul or if you want to process the\n",
      " |      individual arguments of the tail of self as a Mul.\n",
      " |      \n",
      " |      - if you know self is a Mul and want only the head, use self.args[0];\n",
      " |      - if you do not want to process the arguments of the tail but need the\n",
      " |        tail then use self.as_two_terms() which gives the head and tail;\n",
      " |      - if you want to split self into an independent and dependent parts\n",
      " |        use ``self.as_independent(*deps)``\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (S(3)).as_coeff_mul()\n",
      " |      (3, ())\n",
      " |      >>> (3*x*y).as_coeff_mul()\n",
      " |      (3, (x, y))\n",
      " |      >>> (3*x*y).as_coeff_mul(x)\n",
      " |      (3*y, (x,))\n",
      " |      >>> (3*y).as_coeff_mul(x)\n",
      " |      (3*y, ())\n",
      " |  \n",
      " |  as_coefficient(self, expr)\n",
      " |      Extracts symbolic coefficient at the given expression. In\n",
      " |      other words, this functions separates 'self' into the product\n",
      " |      of 'expr' and 'expr'-free coefficient. If such separation\n",
      " |      is not possible it will return None.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import E, pi, sin, I, Poly\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> E.as_coefficient(E)\n",
      " |      1\n",
      " |      >>> (2*E).as_coefficient(E)\n",
      " |      2\n",
      " |      >>> (2*sin(E)*E).as_coefficient(E)\n",
      " |      \n",
      " |      Two terms have E in them so a sum is returned. (If one were\n",
      " |      desiring the coefficient of the term exactly matching E then\n",
      " |      the constant from the returned expression could be selected.\n",
      " |      Or, for greater precision, a method of Poly can be used to\n",
      " |      indicate the desired term from which the coefficient is\n",
      " |      desired.)\n",
      " |      \n",
      " |      >>> (2*E + x*E).as_coefficient(E)\n",
      " |      x + 2\n",
      " |      >>> _.args[0]  # just want the exact match\n",
      " |      2\n",
      " |      >>> p = Poly(2*E + x*E); p\n",
      " |      Poly(x*E + 2*E, x, E, domain='ZZ')\n",
      " |      >>> p.coeff_monomial(E)\n",
      " |      2\n",
      " |      >>> p.nth(0, 1)\n",
      " |      2\n",
      " |      \n",
      " |      Since the following cannot be written as a product containing\n",
      " |      E as a factor, None is returned. (If the coefficient ``2*x`` is\n",
      " |      desired then the ``coeff`` method should be used.)\n",
      " |      \n",
      " |      >>> (2*E*x + x).as_coefficient(E)\n",
      " |      >>> (2*E*x + x).coeff(E)\n",
      " |      2*x\n",
      " |      \n",
      " |      >>> (E*(x + 1) + x).as_coefficient(E)\n",
      " |      \n",
      " |      >>> (2*pi*I).as_coefficient(pi*I)\n",
      " |      2\n",
      " |      >>> (2*I).as_coefficient(pi*I)\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      coeff: return sum of terms have a given factor\n",
      " |      as_coeff_Add: separate the additive constant from an expression\n",
      " |      as_coeff_Mul: separate the multiplicative constant from an expression\n",
      " |      as_independent: separate x-dependent terms/factors from others\n",
      " |      sympy.polys.polytools.Poly.coeff_monomial: efficiently find the single coefficient of a monomial in Poly\n",
      " |      sympy.polys.polytools.Poly.nth: like coeff_monomial but powers of monomial terms are used\n",
      " |  \n",
      " |  as_coefficients_dict(self)\n",
      " |      Return a dictionary mapping terms to their Rational coefficient.\n",
      " |      Since the dictionary is a defaultdict, inquiries about terms which\n",
      " |      were not present will return a coefficient of 0. If an expression is\n",
      " |      not an Add it is considered to have a single term.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import a, x\n",
      " |      >>> (3*x + a*x + 4).as_coefficients_dict()\n",
      " |      {1: 4, x: 3, a*x: 1}\n",
      " |      >>> _[a]\n",
      " |      0\n",
      " |      >>> (3*a*x).as_coefficients_dict()\n",
      " |      {a*x: 3}\n",
      " |  \n",
      " |  as_content_primitive(self, radical=False, clear=True)\n",
      " |      This method should recursively remove a Rational from all arguments\n",
      " |      and return that (content) and the new self (primitive). The content\n",
      " |      should always be positive and ``Mul(*foo.as_content_primitive()) == foo``.\n",
      " |      The primitive need not be in canonical form and should try to preserve\n",
      " |      the underlying structure if possible (i.e. expand_mul should not be\n",
      " |      applied to self).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sqrt\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> eq = 2 + 2*x + 2*y*(3 + 3*y)\n",
      " |      \n",
      " |      The as_content_primitive function is recursive and retains structure:\n",
      " |      \n",
      " |      >>> eq.as_content_primitive()\n",
      " |      (2, x + 3*y*(y + 1) + 1)\n",
      " |      \n",
      " |      Integer powers will have Rationals extracted from the base:\n",
      " |      \n",
      " |      >>> ((2 + 6*x)**2).as_content_primitive()\n",
      " |      (4, (3*x + 1)**2)\n",
      " |      >>> ((2 + 6*x)**(2*y)).as_content_primitive()\n",
      " |      (1, (2*(3*x + 1))**(2*y))\n",
      " |      \n",
      " |      Terms may end up joining once their as_content_primitives are added:\n",
      " |      \n",
      " |      >>> ((5*(x*(1 + y)) + 2*x*(3 + 3*y))).as_content_primitive()\n",
      " |      (11, x*(y + 1))\n",
      " |      >>> ((3*(x*(1 + y)) + 2*x*(3 + 3*y))).as_content_primitive()\n",
      " |      (9, x*(y + 1))\n",
      " |      >>> ((3*(z*(1 + y)) + 2.0*x*(3 + 3*y))).as_content_primitive()\n",
      " |      (1, 6.0*x*(y + 1) + 3*z*(y + 1))\n",
      " |      >>> ((5*(x*(1 + y)) + 2*x*(3 + 3*y))**2).as_content_primitive()\n",
      " |      (121, x**2*(y + 1)**2)\n",
      " |      >>> ((x*(1 + y) + 0.4*x*(3 + 3*y))**2).as_content_primitive()\n",
      " |      (1, 4.84*x**2*(y + 1)**2)\n",
      " |      \n",
      " |      Radical content can also be factored out of the primitive:\n",
      " |      \n",
      " |      >>> (2*sqrt(2) + 4*sqrt(10)).as_content_primitive(radical=True)\n",
      " |      (2, sqrt(2)*(1 + 2*sqrt(5)))\n",
      " |      \n",
      " |      If clear=False (default is True) then content will not be removed\n",
      " |      from an Add if it can be distributed to leave one or more\n",
      " |      terms with integer coefficients.\n",
      " |      \n",
      " |      >>> (x/2 + y).as_content_primitive()\n",
      " |      (1/2, x + 2*y)\n",
      " |      >>> (x/2 + y).as_content_primitive(clear=False)\n",
      " |      (1, x/2 + y)\n",
      " |  \n",
      " |  as_expr(self, *gens)\n",
      " |      Convert a polynomial to a SymPy expression.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> f = (x**2 + x*y).as_poly(x, y)\n",
      " |      >>> f.as_expr()\n",
      " |      x**2 + x*y\n",
      " |      \n",
      " |      >>> sin(x).as_expr()\n",
      " |      sin(x)\n",
      " |  \n",
      " |  as_independent(self, *deps, **hint)\n",
      " |      A mostly naive separation of a Mul or Add into arguments that are not\n",
      " |      are dependent on deps. To obtain as complete a separation of variables\n",
      " |      as possible, use a separation method first, e.g.:\n",
      " |      \n",
      " |      * separatevars() to change Mul, Add and Pow (including exp) into Mul\n",
      " |      * .expand(mul=True) to change Add or Mul into Add\n",
      " |      * .expand(log=True) to change log expr into an Add\n",
      " |      \n",
      " |      The only non-naive thing that is done here is to respect noncommutative\n",
      " |      ordering of variables and to always return (0, 0) for `self` of zero\n",
      " |      regardless of hints.\n",
      " |      \n",
      " |      For nonzero `self`, the returned tuple (i, d) has the\n",
      " |      following interpretation:\n",
      " |      \n",
      " |      * i will has no variable that appears in deps\n",
      " |      * d will either have terms that contain variables that are in deps, or\n",
      " |        be equal to 0 (when self is an Add) or 1 (when self is a Mul)\n",
      " |      * if self is an Add then self = i + d\n",
      " |      * if self is a Mul then self = i*d\n",
      " |      * otherwise (self, S.One) or (S.One, self) is returned.\n",
      " |      \n",
      " |      To force the expression to be treated as an Add, use the hint as_Add=True\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      -- self is an Add\n",
      " |      \n",
      " |      >>> from sympy import sin, cos, exp\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      >>> (x + x*y).as_independent(x)\n",
      " |      (0, x*y + x)\n",
      " |      >>> (x + x*y).as_independent(y)\n",
      " |      (x, x*y)\n",
      " |      >>> (2*x*sin(x) + y + x + z).as_independent(x)\n",
      " |      (y + z, 2*x*sin(x) + x)\n",
      " |      >>> (2*x*sin(x) + y + x + z).as_independent(x, y)\n",
      " |      (z, 2*x*sin(x) + x + y)\n",
      " |      \n",
      " |      -- self is a Mul\n",
      " |      \n",
      " |      >>> (x*sin(x)*cos(y)).as_independent(x)\n",
      " |      (cos(y), x*sin(x))\n",
      " |      \n",
      " |      non-commutative terms cannot always be separated out when self is a Mul\n",
      " |      \n",
      " |      >>> from sympy import symbols\n",
      " |      >>> n1, n2, n3 = symbols('n1 n2 n3', commutative=False)\n",
      " |      >>> (n1 + n1*n2).as_independent(n2)\n",
      " |      (n1, n1*n2)\n",
      " |      >>> (n2*n1 + n1*n2).as_independent(n2)\n",
      " |      (0, n1*n2 + n2*n1)\n",
      " |      >>> (n1*n2*n3).as_independent(n1)\n",
      " |      (1, n1*n2*n3)\n",
      " |      >>> (n1*n2*n3).as_independent(n2)\n",
      " |      (n1, n2*n3)\n",
      " |      >>> ((x-n1)*(x-y)).as_independent(x)\n",
      " |      (1, (x - y)*(x - n1))\n",
      " |      \n",
      " |      -- self is anything else:\n",
      " |      \n",
      " |      >>> (sin(x)).as_independent(x)\n",
      " |      (1, sin(x))\n",
      " |      >>> (sin(x)).as_independent(y)\n",
      " |      (sin(x), 1)\n",
      " |      >>> exp(x+y).as_independent(x)\n",
      " |      (1, exp(x + y))\n",
      " |      \n",
      " |      -- force self to be treated as an Add:\n",
      " |      \n",
      " |      >>> (3*x).as_independent(x, as_Add=True)\n",
      " |      (0, 3*x)\n",
      " |      \n",
      " |      -- force self to be treated as a Mul:\n",
      " |      \n",
      " |      >>> (3+x).as_independent(x, as_Add=False)\n",
      " |      (1, x + 3)\n",
      " |      >>> (-3+x).as_independent(x, as_Add=False)\n",
      " |      (1, x - 3)\n",
      " |      \n",
      " |      Note how the below differs from the above in making the\n",
      " |      constant on the dep term positive.\n",
      " |      \n",
      " |      >>> (y*(-3+x)).as_independent(x)\n",
      " |      (y, x - 3)\n",
      " |      \n",
      " |      -- use .as_independent() for true independence testing instead\n",
      " |         of .has(). The former considers only symbols in the free\n",
      " |         symbols while the latter considers all symbols\n",
      " |      \n",
      " |      >>> from sympy import Integral\n",
      " |      >>> I = Integral(x, (x, 1, 2))\n",
      " |      >>> I.has(x)\n",
      " |      True\n",
      " |      >>> x in I.free_symbols\n",
      " |      False\n",
      " |      >>> I.as_independent(x) == (I, 1)\n",
      " |      True\n",
      " |      >>> (I + x).as_independent(x) == (I, x)\n",
      " |      True\n",
      " |      \n",
      " |      Note: when trying to get independent terms, a separation method\n",
      " |      might need to be used first. In this case, it is important to keep\n",
      " |      track of what you send to this routine so you know how to interpret\n",
      " |      the returned values\n",
      " |      \n",
      " |      >>> from sympy import separatevars, log\n",
      " |      >>> separatevars(exp(x+y)).as_independent(x)\n",
      " |      (exp(y), exp(x))\n",
      " |      >>> (x + x*y).as_independent(y)\n",
      " |      (x, x*y)\n",
      " |      >>> separatevars(x + x*y).as_independent(y)\n",
      " |      (x, y + 1)\n",
      " |      >>> (x*(1 + y)).as_independent(y)\n",
      " |      (x, y + 1)\n",
      " |      >>> (x*(1 + y)).expand(mul=True).as_independent(y)\n",
      " |      (x, x*y)\n",
      " |      >>> a, b=symbols('a b', positive=True)\n",
      " |      >>> (log(a*b).expand(log=True)).as_independent(b)\n",
      " |      (log(a), log(b))\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      .separatevars(), .expand(log=True), sympy.core.add.Add.as_two_terms(),\n",
      " |      sympy.core.mul.Mul.as_two_terms(), .as_coeff_add(), .as_coeff_mul()\n",
      " |  \n",
      " |  as_leading_term(self, *symbols, logx=None, cdir=0)\n",
      " |      Returns the leading (nonzero) term of the series expansion of self.\n",
      " |      \n",
      " |      The _eval_as_leading_term routines are used to do this, and they must\n",
      " |      always return a non-zero value.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> (1 + x + x**2).as_leading_term(x)\n",
      " |      1\n",
      " |      >>> (1/x**2 + x + x**2).as_leading_term(x)\n",
      " |      x**(-2)\n",
      " |  \n",
      " |  as_numer_denom(self)\n",
      " |      expression -> a/b -> a, b\n",
      " |      \n",
      " |      This is just a stub that should be defined by\n",
      " |      an object's class methods to get anything else.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      normal: return ``a/b`` instead of ``(a, b)``\n",
      " |  \n",
      " |  as_ordered_factors(self, order=None)\n",
      " |      Return list of ordered factors (if Mul) else [self].\n",
      " |  \n",
      " |  as_ordered_terms(self, order=None, data=False)\n",
      " |      Transform an expression to an ordered list of terms.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin, cos\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> (sin(x)**2*cos(x) + sin(x)**2 + 1).as_ordered_terms()\n",
      " |      [sin(x)**2*cos(x), sin(x)**2, 1]\n",
      " |  \n",
      " |  as_poly(self, *gens, **args)\n",
      " |      Converts ``self`` to a polynomial or returns ``None``.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> print((x**2 + x*y).as_poly())\n",
      " |      Poly(x**2 + x*y, x, y, domain='ZZ')\n",
      " |      \n",
      " |      >>> print((x**2 + x*y).as_poly(x, y))\n",
      " |      Poly(x**2 + x*y, x, y, domain='ZZ')\n",
      " |      \n",
      " |      >>> print((x**2 + sin(y)).as_poly(x, y))\n",
      " |      None\n",
      " |  \n",
      " |  as_powers_dict(self)\n",
      " |      Return self as a dictionary of factors with each factor being\n",
      " |      treated as a power. The keys are the bases of the factors and the\n",
      " |      values, the corresponding exponents. The resulting dictionary should\n",
      " |      be used with caution if the expression is a Mul and contains non-\n",
      " |      commutative factors since the order that they appeared will be lost in\n",
      " |      the dictionary.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      as_ordered_factors: An alternative for noncommutative applications,\n",
      " |                          returning an ordered list of factors.\n",
      " |      args_cnc: Similar to as_ordered_factors, but guarantees separation\n",
      " |                of commutative and noncommutative factors.\n",
      " |  \n",
      " |  as_real_imag(self, deep=True, **hints)\n",
      " |      Performs complex expansion on 'self' and returns a tuple\n",
      " |      containing collected both real and imaginary parts. This\n",
      " |      method cannot be confused with re() and im() functions,\n",
      " |      which does not perform complex expansion at evaluation.\n",
      " |      \n",
      " |      However it is possible to expand both re() and im()\n",
      " |      functions and get exactly the same results as with\n",
      " |      a single call to this function.\n",
      " |      \n",
      " |      >>> from sympy import symbols, I\n",
      " |      \n",
      " |      >>> x, y = symbols('x,y', real=True)\n",
      " |      \n",
      " |      >>> (x + y*I).as_real_imag()\n",
      " |      (x, y)\n",
      " |      \n",
      " |      >>> from sympy.abc import z, w\n",
      " |      \n",
      " |      >>> (z + w*I).as_real_imag()\n",
      " |      (re(z) - im(w), re(w) + im(z))\n",
      " |  \n",
      " |  as_terms(self)\n",
      " |      Transform an expression to a list of terms.\n",
      " |  \n",
      " |  aseries(self, x=None, n=6, bound=0, hir=False)\n",
      " |      Asymptotic Series expansion of self.\n",
      " |      This is equivalent to ``self.series(x, oo, n)``.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      self : Expression\n",
      " |             The expression whose series is to be expanded.\n",
      " |      \n",
      " |      x : Symbol\n",
      " |          It is the variable of the expression to be calculated.\n",
      " |      \n",
      " |      n : Value\n",
      " |          The number of terms upto which the series is to be expanded.\n",
      " |      \n",
      " |      hir : Boolean\n",
      " |            Set this parameter to be True to produce hierarchical series.\n",
      " |            It stops the recursion at an early level and may provide nicer\n",
      " |            and more useful results.\n",
      " |      \n",
      " |      bound : Value, Integer\n",
      " |              Use the ``bound`` parameter to give limit on rewriting\n",
      " |              coefficients in its normalised form.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin, exp\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> e = sin(1/x + exp(-x)) - sin(1/x)\n",
      " |      \n",
      " |      >>> e.aseries(x)\n",
      " |      (1/(24*x**4) - 1/(2*x**2) + 1 + O(x**(-6), (x, oo)))*exp(-x)\n",
      " |      \n",
      " |      >>> e.aseries(x, n=3, hir=True)\n",
      " |      -exp(-2*x)*sin(1/x)/2 + exp(-x)*cos(1/x) + O(exp(-3*x), (x, oo))\n",
      " |      \n",
      " |      >>> e = exp(exp(x)/(1 - 1/x))\n",
      " |      \n",
      " |      >>> e.aseries(x)\n",
      " |      exp(exp(x)/(1 - 1/x))\n",
      " |      \n",
      " |      >>> e.aseries(x, bound=3) # doctest: +SKIP\n",
      " |      exp(exp(x)/x**2)*exp(exp(x)/x)*exp(-exp(x) + exp(x)/(1 - 1/x) - exp(x)/x - exp(x)/x**2)*exp(exp(x))\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      Expr\n",
      " |          Asymptotic series expansion of the expression.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      This algorithm is directly induced from the limit computational algorithm provided by Gruntz.\n",
      " |      It majorly uses the mrv and rewrite sub-routines. The overall idea of this algorithm is first\n",
      " |      to look for the most rapidly varying subexpression w of a given expression f and then expands f\n",
      " |      in a series in w. Then same thing is recursively done on the leading coefficient\n",
      " |      till we get constant coefficients.\n",
      " |      \n",
      " |      If the most rapidly varying subexpression of a given expression f is f itself,\n",
      " |      the algorithm tries to find a normalised representation of the mrv set and rewrites f\n",
      " |      using this normalised representation.\n",
      " |      \n",
      " |      If the expansion contains an order term, it will be either ``O(x ** (-n))`` or ``O(w ** (-n))``\n",
      " |      where ``w`` belongs to the most rapidly varying expression of ``self``.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] Gruntz, Dominik. A new algorithm for computing asymptotic series.\n",
      " |             In: Proc. 1993 Int. Symp. Symbolic and Algebraic Computation. 1993.\n",
      " |             pp. 239-244.\n",
      " |      .. [2] Gruntz thesis - p90\n",
      " |      .. [3] http://en.wikipedia.org/wiki/Asymptotic_expansion\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      Expr.aseries: See the docstring of this function for complete details of this wrapper.\n",
      " |  \n",
      " |  cancel(self, *gens, **args)\n",
      " |      See the cancel function in sympy.polys\n",
      " |  \n",
      " |  coeff(self, x, n=1, right=False, _first=True)\n",
      " |      Returns the coefficient from the term(s) containing ``x**n``. If ``n``\n",
      " |      is zero then all terms independent of ``x`` will be returned.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      When ``x`` is noncommutative, the coefficient to the left (default) or\n",
      " |      right of ``x`` can be returned. The keyword 'right' is ignored when\n",
      " |      ``x`` is commutative.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      \n",
      " |      You can select terms that have an explicit negative in front of them:\n",
      " |      \n",
      " |      >>> (-x + 2*y).coeff(-1)\n",
      " |      x\n",
      " |      >>> (x - 2*y).coeff(-1)\n",
      " |      2*y\n",
      " |      \n",
      " |      You can select terms with no Rational coefficient:\n",
      " |      \n",
      " |      >>> (x + 2*y).coeff(1)\n",
      " |      x\n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(1)\n",
      " |      0\n",
      " |      \n",
      " |      You can select terms independent of x by making n=0; in this case\n",
      " |      expr.as_independent(x)[0] is returned (and 0 will be returned instead\n",
      " |      of None):\n",
      " |      \n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(x, 0)\n",
      " |      3\n",
      " |      >>> eq = ((x + 1)**3).expand() + 1\n",
      " |      >>> eq\n",
      " |      x**3 + 3*x**2 + 3*x + 2\n",
      " |      >>> [eq.coeff(x, i) for i in reversed(range(4))]\n",
      " |      [1, 3, 3, 2]\n",
      " |      >>> eq -= 2\n",
      " |      >>> [eq.coeff(x, i) for i in reversed(range(4))]\n",
      " |      [1, 3, 3, 0]\n",
      " |      \n",
      " |      You can select terms that have a numerical term in front of them:\n",
      " |      \n",
      " |      >>> (-x - 2*y).coeff(2)\n",
      " |      -y\n",
      " |      >>> from sympy import sqrt\n",
      " |      >>> (x + sqrt(2)*x).coeff(sqrt(2))\n",
      " |      x\n",
      " |      \n",
      " |      The matching is exact:\n",
      " |      \n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(x)\n",
      " |      2\n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(x**2)\n",
      " |      4\n",
      " |      >>> (3 + 2*x + 4*x**2).coeff(x**3)\n",
      " |      0\n",
      " |      >>> (z*(x + y)**2).coeff((x + y)**2)\n",
      " |      z\n",
      " |      >>> (z*(x + y)**2).coeff(x + y)\n",
      " |      0\n",
      " |      \n",
      " |      In addition, no factoring is done, so 1 + z*(1 + y) is not obtained\n",
      " |      from the following:\n",
      " |      \n",
      " |      >>> (x + z*(x + x*y)).coeff(x)\n",
      " |      1\n",
      " |      \n",
      " |      If such factoring is desired, factor_terms can be used first:\n",
      " |      \n",
      " |      >>> from sympy import factor_terms\n",
      " |      >>> factor_terms(x + z*(x + x*y)).coeff(x)\n",
      " |      z*(y + 1) + 1\n",
      " |      \n",
      " |      >>> n, m, o = symbols('n m o', commutative=False)\n",
      " |      >>> n.coeff(n)\n",
      " |      1\n",
      " |      >>> (3*n).coeff(n)\n",
      " |      3\n",
      " |      >>> (n*m + m*n*m).coeff(n) # = (1 + m)*n*m\n",
      " |      1 + m\n",
      " |      >>> (n*m + m*n*m).coeff(n, right=True) # = (1 + m)*n*m\n",
      " |      m\n",
      " |      \n",
      " |      If there is more than one possible coefficient 0 is returned:\n",
      " |      \n",
      " |      >>> (n*m + m*n).coeff(n)\n",
      " |      0\n",
      " |      \n",
      " |      If there is only one possible coefficient, it is returned:\n",
      " |      \n",
      " |      >>> (n*m + x*m*n).coeff(m*n)\n",
      " |      x\n",
      " |      >>> (n*m + x*m*n).coeff(m*n, right=1)\n",
      " |      1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      as_coefficient: separate the expression into a coefficient and factor\n",
      " |      as_coeff_Add: separate the additive constant from an expression\n",
      " |      as_coeff_Mul: separate the multiplicative constant from an expression\n",
      " |      as_independent: separate x-dependent terms/factors from others\n",
      " |      sympy.polys.polytools.Poly.coeff_monomial: efficiently find the single coefficient of a monomial in Poly\n",
      " |      sympy.polys.polytools.Poly.nth: like coeff_monomial but powers of monomial terms are used\n",
      " |  \n",
      " |  collect(self, syms, func=None, evaluate=True, exact=False, distribute_order_term=True)\n",
      " |      See the collect function in sympy.simplify\n",
      " |  \n",
      " |  combsimp(self)\n",
      " |      See the combsimp function in sympy.simplify\n",
      " |  \n",
      " |  compute_leading_term(self, x, logx=None)\n",
      " |      as_leading_term is only allowed for results of .series()\n",
      " |      This is a wrapper to compute a series first.\n",
      " |  \n",
      " |  conjugate(self)\n",
      " |      Returns the complex conjugate of 'self'.\n",
      " |  \n",
      " |  could_extract_minus_sign(self)\n",
      " |      Return True if self has -1 as a leading factor or has\n",
      " |      more literal negative signs than positive signs in a sum,\n",
      " |      otherwise False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> e = x - y\n",
      " |      >>> {i.could_extract_minus_sign() for i in (e, -e)}\n",
      " |      {False, True}\n",
      " |      \n",
      " |      Though the ``y - x`` is considered like ``-(x - y)``, since it\n",
      " |      is in a product without a leading factor of -1, the result is\n",
      " |      false below:\n",
      " |      \n",
      " |      >>> (x*(y - x)).could_extract_minus_sign()\n",
      " |      False\n",
      " |      \n",
      " |      To put something in canonical form wrt to sign, use `signsimp`:\n",
      " |      \n",
      " |      >>> from sympy import signsimp\n",
      " |      >>> signsimp(x*(y - x))\n",
      " |      -x*(x - y)\n",
      " |      >>> _.could_extract_minus_sign()\n",
      " |      True\n",
      " |  \n",
      " |  count_ops(self, visual=None)\n",
      " |      wrapper for count_ops that returns the operation count.\n",
      " |  \n",
      " |  diff(self, *symbols, **assumptions)\n",
      " |  \n",
      " |  dir(self, x, cdir)\n",
      " |  \n",
      " |  equals(self, other, failing_expression=False)\n",
      " |      Return True if self == other, False if it doesn't, or None. If\n",
      " |      failing_expression is True then the expression which did not simplify\n",
      " |      to a 0 will be returned instead of None.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      If ``self`` is a Number (or complex number) that is not zero, then\n",
      " |      the result is False.\n",
      " |      \n",
      " |      If ``self`` is a number and has not evaluated to zero, evalf will be\n",
      " |      used to test whether the expression evaluates to zero. If it does so\n",
      " |      and the result has significance (i.e. the precision is either -1, for\n",
      " |      a Rational result, or is greater than 1) then the evalf value will be\n",
      " |      used to return True or False.\n",
      " |  \n",
      " |  expand(self, deep=True, modulus=None, power_base=True, power_exp=True, mul=True, log=True, multinomial=True, basic=True, **hints)\n",
      " |      Expand an expression using hints.\n",
      " |      \n",
      " |      See the docstring of the expand() function in sympy.core.function for\n",
      " |      more information.\n",
      " |  \n",
      " |  extract_additively(self, c)\n",
      " |      Return self - c if it's possible to subtract c from self and\n",
      " |      make all matching coefficients move towards zero, else return None.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> e = 2*x + 3\n",
      " |      >>> e.extract_additively(x + 1)\n",
      " |      x + 2\n",
      " |      >>> e.extract_additively(3*x)\n",
      " |      >>> e.extract_additively(4)\n",
      " |      >>> (y*(x + 1)).extract_additively(x + 1)\n",
      " |      >>> ((x + 1)*(x + 2*y + 1) + 3).extract_additively(x + 1)\n",
      " |      (x + 1)*(x + 2*y) + 3\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      extract_multiplicatively\n",
      " |      coeff\n",
      " |      as_coefficient\n",
      " |  \n",
      " |  extract_branch_factor(self, allow_half=False)\n",
      " |      Try to write self as ``exp_polar(2*pi*I*n)*z`` in a nice way.\n",
      " |      Return (z, n).\n",
      " |      \n",
      " |      >>> from sympy import exp_polar, I, pi\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> exp_polar(I*pi).extract_branch_factor()\n",
      " |      (exp_polar(I*pi), 0)\n",
      " |      >>> exp_polar(2*I*pi).extract_branch_factor()\n",
      " |      (1, 1)\n",
      " |      >>> exp_polar(-pi*I).extract_branch_factor()\n",
      " |      (exp_polar(I*pi), -1)\n",
      " |      >>> exp_polar(3*pi*I + x).extract_branch_factor()\n",
      " |      (exp_polar(x + I*pi), 1)\n",
      " |      >>> (y*exp_polar(-5*pi*I)*exp_polar(3*pi*I + 2*pi*x)).extract_branch_factor()\n",
      " |      (y*exp_polar(2*pi*x), -1)\n",
      " |      >>> exp_polar(-I*pi/2).extract_branch_factor()\n",
      " |      (exp_polar(-I*pi/2), 0)\n",
      " |      \n",
      " |      If allow_half is True, also extract exp_polar(I*pi):\n",
      " |      \n",
      " |      >>> exp_polar(I*pi).extract_branch_factor(allow_half=True)\n",
      " |      (1, 1/2)\n",
      " |      >>> exp_polar(2*I*pi).extract_branch_factor(allow_half=True)\n",
      " |      (1, 1)\n",
      " |      >>> exp_polar(3*I*pi).extract_branch_factor(allow_half=True)\n",
      " |      (1, 3/2)\n",
      " |      >>> exp_polar(-I*pi).extract_branch_factor(allow_half=True)\n",
      " |      (1, -1/2)\n",
      " |  \n",
      " |  extract_multiplicatively(self, c)\n",
      " |      Return None if it's not possible to make self in the form\n",
      " |      c * something in a nice way, i.e. preserving the properties\n",
      " |      of arguments of self.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, Rational\n",
      " |      \n",
      " |      >>> x, y = symbols('x,y', real=True)\n",
      " |      \n",
      " |      >>> ((x*y)**3).extract_multiplicatively(x**2 * y)\n",
      " |      x*y**2\n",
      " |      \n",
      " |      >>> ((x*y)**3).extract_multiplicatively(x**4 * y)\n",
      " |      \n",
      " |      >>> (2*x).extract_multiplicatively(2)\n",
      " |      x\n",
      " |      \n",
      " |      >>> (2*x).extract_multiplicatively(3)\n",
      " |      \n",
      " |      >>> (Rational(1, 2)*x).extract_multiplicatively(3)\n",
      " |      x/6\n",
      " |  \n",
      " |  factor(self, *gens, **args)\n",
      " |      See the factor() function in sympy.polys.polytools\n",
      " |  \n",
      " |  fourier_series(self, limits=None)\n",
      " |      Compute fourier sine/cosine series of self.\n",
      " |      \n",
      " |      See the docstring of the :func:`fourier_series` in sympy.series.fourier\n",
      " |      for more information.\n",
      " |  \n",
      " |  fps(self, x=None, x0=0, dir=1, hyper=True, order=4, rational=True, full=False)\n",
      " |      Compute formal power power series of self.\n",
      " |      \n",
      " |      See the docstring of the :func:`fps` function in sympy.series.formal for\n",
      " |      more information.\n",
      " |  \n",
      " |  gammasimp(self)\n",
      " |      See the gammasimp function in sympy.simplify\n",
      " |  \n",
      " |  getO(self)\n",
      " |      Returns the additive O(..) symbol if there is one, else None.\n",
      " |  \n",
      " |  getn(self)\n",
      " |      Returns the order of the expression.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      The order is determined either from the O(...) term. If there\n",
      " |      is no O(...) term, it returns None.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import O\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> (1 + x + O(x**2)).getn()\n",
      " |      2\n",
      " |      >>> (1 + x).getn()\n",
      " |  \n",
      " |  integrate(self, *args, **kwargs)\n",
      " |      See the integrate function in sympy.integrals\n",
      " |  \n",
      " |  invert(self, g, *gens, **args)\n",
      " |      Return the multiplicative inverse of ``self`` mod ``g``\n",
      " |      where ``self`` (and ``g``) may be symbolic expressions).\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      sympy.core.numbers.mod_inverse, sympy.polys.polytools.invert\n",
      " |  \n",
      " |  is_algebraic_expr(self, *syms)\n",
      " |      This tests whether a given expression is algebraic or not, in the\n",
      " |      given symbols, syms. When syms is not given, all free symbols\n",
      " |      will be used. The rational function does not have to be in expanded\n",
      " |      or in any kind of canonical form.\n",
      " |      \n",
      " |      This function returns False for expressions that are \"algebraic\n",
      " |      expressions\" with symbolic exponents. This is a simple extension to the\n",
      " |      is_rational_function, including rational exponentiation.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol, sqrt\n",
      " |      >>> x = Symbol('x', real=True)\n",
      " |      >>> sqrt(1 + x).is_rational_function()\n",
      " |      False\n",
      " |      >>> sqrt(1 + x).is_algebraic_expr()\n",
      " |      True\n",
      " |      \n",
      " |      This function does not attempt any nontrivial simplifications that may\n",
      " |      result in an expression that does not appear to be an algebraic\n",
      " |      expression to become one.\n",
      " |      \n",
      " |      >>> from sympy import exp, factor\n",
      " |      >>> a = sqrt(exp(x)**2 + 2*exp(x) + 1)/(exp(x) + 1)\n",
      " |      >>> a.is_algebraic_expr(x)\n",
      " |      False\n",
      " |      >>> factor(a).is_algebraic_expr()\n",
      " |      True\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      is_rational_function()\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      .. [1] https://en.wikipedia.org/wiki/Algebraic_expression\n",
      " |  \n",
      " |  is_constant(self, *wrt, **flags)\n",
      " |      Return True if self is constant, False if not, or None if\n",
      " |      the constancy could not be determined conclusively.\n",
      " |      \n",
      " |      Explanation\n",
      " |      ===========\n",
      " |      \n",
      " |      If an expression has no free symbols then it is a constant. If\n",
      " |      there are free symbols it is possible that the expression is a\n",
      " |      constant, perhaps (but not necessarily) zero. To test such\n",
      " |      expressions, a few strategies are tried:\n",
      " |      \n",
      " |      1) numerical evaluation at two random points. If two such evaluations\n",
      " |      give two different values and the values have a precision greater than\n",
      " |      1 then self is not constant. If the evaluations agree or could not be\n",
      " |      obtained with any precision, no decision is made. The numerical testing\n",
      " |      is done only if ``wrt`` is different than the free symbols.\n",
      " |      \n",
      " |      2) differentiation with respect to variables in 'wrt' (or all free\n",
      " |      symbols if omitted) to see if the expression is constant or not. This\n",
      " |      will not always lead to an expression that is zero even though an\n",
      " |      expression is constant (see added test in test_expr.py). If\n",
      " |      all derivatives are zero then self is constant with respect to the\n",
      " |      given symbols.\n",
      " |      \n",
      " |      3) finding out zeros of denominator expression with free_symbols.\n",
      " |      It will not be constant if there are zeros. It gives more negative\n",
      " |      answers for expression that are not constant.\n",
      " |      \n",
      " |      If neither evaluation nor differentiation can prove the expression is\n",
      " |      constant, None is returned unless two numerical values happened to be\n",
      " |      the same and the flag ``failing_number`` is True -- in that case the\n",
      " |      numerical value will be returned.\n",
      " |      \n",
      " |      If flag simplify=False is passed, self will not be simplified;\n",
      " |      the default is True since self should be simplified before testing.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cos, sin, Sum, S, pi\n",
      " |      >>> from sympy.abc import a, n, x, y\n",
      " |      >>> x.is_constant()\n",
      " |      False\n",
      " |      >>> S(2).is_constant()\n",
      " |      True\n",
      " |      >>> Sum(x, (x, 1, 10)).is_constant()\n",
      " |      True\n",
      " |      >>> Sum(x, (x, 1, n)).is_constant()\n",
      " |      False\n",
      " |      >>> Sum(x, (x, 1, n)).is_constant(y)\n",
      " |      True\n",
      " |      >>> Sum(x, (x, 1, n)).is_constant(n)\n",
      " |      False\n",
      " |      >>> Sum(x, (x, 1, n)).is_constant(x)\n",
      " |      True\n",
      " |      >>> eq = a*cos(x)**2 + a*sin(x)**2 - a\n",
      " |      >>> eq.is_constant()\n",
      " |      True\n",
      " |      >>> eq.subs({x: pi, a: 2}) == eq.subs({x: pi, a: 3}) == 0\n",
      " |      True\n",
      " |      \n",
      " |      >>> (0**x).is_constant()\n",
      " |      False\n",
      " |      >>> x.is_constant()\n",
      " |      False\n",
      " |      >>> (x**x).is_constant()\n",
      " |      False\n",
      " |      >>> one = cos(x)**2 + sin(x)**2\n",
      " |      >>> one.is_constant()\n",
      " |      True\n",
      " |      >>> ((one - 1)**(x + 1)).is_constant() in (True, False) # could be 0 or 1\n",
      " |      True\n",
      " |  \n",
      " |  is_meromorphic(self, x, a)\n",
      " |      This tests whether an expression is meromorphic as\n",
      " |      a function of the given symbol ``x`` at the point ``a``.\n",
      " |      \n",
      " |      This method is intended as a quick test that will return\n",
      " |      None if no decision can be made without simplification or\n",
      " |      more detailed analysis.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import zoo, log, sin, sqrt\n",
      " |      >>> from sympy.abc import x\n",
      " |      \n",
      " |      >>> f = 1/x**2 + 1 - 2*x**3\n",
      " |      >>> f.is_meromorphic(x, 0)\n",
      " |      True\n",
      " |      >>> f.is_meromorphic(x, 1)\n",
      " |      True\n",
      " |      >>> f.is_meromorphic(x, zoo)\n",
      " |      True\n",
      " |      \n",
      " |      >>> g = x**log(3)\n",
      " |      >>> g.is_meromorphic(x, 0)\n",
      " |      False\n",
      " |      >>> g.is_meromorphic(x, 1)\n",
      " |      True\n",
      " |      >>> g.is_meromorphic(x, zoo)\n",
      " |      False\n",
      " |      \n",
      " |      >>> h = sin(1/x)*x**2\n",
      " |      >>> h.is_meromorphic(x, 0)\n",
      " |      False\n",
      " |      >>> h.is_meromorphic(x, 1)\n",
      " |      True\n",
      " |      >>> h.is_meromorphic(x, zoo)\n",
      " |      True\n",
      " |      \n",
      " |      Multivalued functions are considered meromorphic when their\n",
      " |      branches are meromorphic. Thus most functions are meromorphic\n",
      " |      everywhere except at essential singularities and branch points.\n",
      " |      In particular, they will be meromorphic also on branch cuts\n",
      " |      except at their endpoints.\n",
      " |      \n",
      " |      >>> log(x).is_meromorphic(x, -1)\n",
      " |      True\n",
      " |      >>> log(x).is_meromorphic(x, 0)\n",
      " |      False\n",
      " |      >>> sqrt(x).is_meromorphic(x, -1)\n",
      " |      True\n",
      " |      >>> sqrt(x).is_meromorphic(x, 0)\n",
      " |      False\n",
      " |  \n",
      " |  is_polynomial(self, *syms)\n",
      " |      Return True if self is a polynomial in syms and False otherwise.\n",
      " |      \n",
      " |      This checks if self is an exact polynomial in syms.  This function\n",
      " |      returns False for expressions that are \"polynomials\" with symbolic\n",
      " |      exponents.  Thus, you should be able to apply polynomial algorithms to\n",
      " |      expressions for which this returns True, and Poly(expr, \\*syms) should\n",
      " |      work if and only if expr.is_polynomial(\\*syms) returns True. The\n",
      " |      polynomial does not have to be in expanded form.  If no symbols are\n",
      " |      given, all free symbols in the expression will be used.\n",
      " |      \n",
      " |      This is not part of the assumptions system.  You cannot do\n",
      " |      Symbol('z', polynomial=True).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol, Function\n",
      " |      >>> x = Symbol('x')\n",
      " |      >>> ((x**2 + 1)**4).is_polynomial(x)\n",
      " |      True\n",
      " |      >>> ((x**2 + 1)**4).is_polynomial()\n",
      " |      True\n",
      " |      >>> (2**x + 1).is_polynomial(x)\n",
      " |      False\n",
      " |      >>> (2**x + 1).is_polynomial(2**x)\n",
      " |      True\n",
      " |      >>> f = Function('f')\n",
      " |      >>> (f(x) + 1).is_polynomial(x)\n",
      " |      False\n",
      " |      >>> (f(x) + 1).is_polynomial(f(x))\n",
      " |      True\n",
      " |      >>> (1/f(x) + 1).is_polynomial(f(x))\n",
      " |      False\n",
      " |      \n",
      " |      >>> n = Symbol('n', nonnegative=True, integer=True)\n",
      " |      >>> (x**n + 1).is_polynomial(x)\n",
      " |      False\n",
      " |      \n",
      " |      This function does not attempt any nontrivial simplifications that may\n",
      " |      result in an expression that does not appear to be a polynomial to\n",
      " |      become one.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, factor, cancel\n",
      " |      >>> y = Symbol('y', positive=True)\n",
      " |      >>> a = sqrt(y**2 + 2*y + 1)\n",
      " |      >>> a.is_polynomial(y)\n",
      " |      False\n",
      " |      >>> factor(a)\n",
      " |      y + 1\n",
      " |      >>> factor(a).is_polynomial(y)\n",
      " |      True\n",
      " |      \n",
      " |      >>> b = (y**2 + 2*y + 1)/(y + 1)\n",
      " |      >>> b.is_polynomial(y)\n",
      " |      False\n",
      " |      >>> cancel(b)\n",
      " |      y + 1\n",
      " |      >>> cancel(b).is_polynomial(y)\n",
      " |      True\n",
      " |      \n",
      " |      See also .is_rational_function()\n",
      " |  \n",
      " |  is_rational_function(self, *syms)\n",
      " |      Test whether function is a ratio of two polynomials in the given\n",
      " |      symbols, syms. When syms is not given, all free symbols will be used.\n",
      " |      The rational function does not have to be in expanded or in any kind of\n",
      " |      canonical form.\n",
      " |      \n",
      " |      This function returns False for expressions that are \"rational\n",
      " |      functions\" with symbolic exponents.  Thus, you should be able to call\n",
      " |      .as_numer_denom() and apply polynomial algorithms to the result for\n",
      " |      expressions for which this returns True.\n",
      " |      \n",
      " |      This is not part of the assumptions system.  You cannot do\n",
      " |      Symbol('z', rational_function=True).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol, sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> (x/y).is_rational_function()\n",
      " |      True\n",
      " |      \n",
      " |      >>> (x**2).is_rational_function()\n",
      " |      True\n",
      " |      \n",
      " |      >>> (x/sin(y)).is_rational_function(y)\n",
      " |      False\n",
      " |      \n",
      " |      >>> n = Symbol('n', integer=True)\n",
      " |      >>> (x**n + 1).is_rational_function(x)\n",
      " |      False\n",
      " |      \n",
      " |      This function does not attempt any nontrivial simplifications that may\n",
      " |      result in an expression that does not appear to be a rational function\n",
      " |      to become one.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, factor\n",
      " |      >>> y = Symbol('y', positive=True)\n",
      " |      >>> a = sqrt(y**2 + 2*y + 1)/y\n",
      " |      >>> a.is_rational_function(y)\n",
      " |      False\n",
      " |      >>> factor(a)\n",
      " |      (y + 1)/y\n",
      " |      >>> factor(a).is_rational_function(y)\n",
      " |      True\n",
      " |      \n",
      " |      See also is_algebraic_expr().\n",
      " |  \n",
      " |  leadterm(self, x, logx=None, cdir=0)\n",
      " |      Returns the leading term a*x**b as a tuple (a, b).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> (1+x+x**2).leadterm(x)\n",
      " |      (1, 0)\n",
      " |      >>> (1/x**2+x+x**2).leadterm(x)\n",
      " |      (1, -2)\n",
      " |  \n",
      " |  limit(self, x, xlim, dir='+')\n",
      " |      Compute limit x->xlim.\n",
      " |  \n",
      " |  lseries(self, x=None, x0=0, dir='+', logx=None, cdir=0)\n",
      " |      Wrapper for series yielding an iterator of the terms of the series.\n",
      " |      \n",
      " |      Note: an infinite series will yield an infinite iterator. The following,\n",
      " |      for exaxmple, will never terminate. It will just keep printing terms\n",
      " |      of the sin(x) series::\n",
      " |      \n",
      " |        for term in sin(x).lseries(x):\n",
      " |            print term\n",
      " |      \n",
      " |      The advantage of lseries() over nseries() is that many times you are\n",
      " |      just interested in the next term in the series (i.e. the first term for\n",
      " |      example), but you do not know how many you should ask for in nseries()\n",
      " |      using the \"n\" parameter.\n",
      " |      \n",
      " |      See also nseries().\n",
      " |  \n",
      " |  normal(self)\n",
      " |      expression -> a/b\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      as_numer_denom: return ``(a, b)`` instead of ``a/b``\n",
      " |  \n",
      " |  nseries(self, x=None, x0=0, n=6, dir='+', logx=None, cdir=0)\n",
      " |      Wrapper to _eval_nseries if assumptions allow, else to series.\n",
      " |      \n",
      " |      If x is given, x0 is 0, dir='+', and self has x, then _eval_nseries is\n",
      " |      called. This calculates \"n\" terms in the innermost expressions and\n",
      " |      then builds up the final series just by \"cross-multiplying\" everything\n",
      " |      out.\n",
      " |      \n",
      " |      The optional ``logx`` parameter can be used to replace any log(x) in the\n",
      " |      returned series with a symbolic value to avoid evaluating log(x) at 0. A\n",
      " |      symbol to use in place of log(x) should be provided.\n",
      " |      \n",
      " |      Advantage -- it's fast, because we do not have to determine how many\n",
      " |      terms we need to calculate in advance.\n",
      " |      \n",
      " |      Disadvantage -- you may end up with less terms than you may have\n",
      " |      expected, but the O(x**n) term appended will always be correct and\n",
      " |      so the result, though perhaps shorter, will also be correct.\n",
      " |      \n",
      " |      If any of those assumptions is not met, this is treated like a\n",
      " |      wrapper to series which will try harder to return the correct\n",
      " |      number of terms.\n",
      " |      \n",
      " |      See also lseries().\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin, log, Symbol\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> sin(x).nseries(x, 0, 6)\n",
      " |      x - x**3/6 + x**5/120 + O(x**6)\n",
      " |      >>> log(x+1).nseries(x, 0, 5)\n",
      " |      x - x**2/2 + x**3/3 - x**4/4 + O(x**5)\n",
      " |      \n",
      " |      Handling of the ``logx`` parameter --- in the following example the\n",
      " |      expansion fails since ``sin`` does not have an asymptotic expansion\n",
      " |      at -oo (the limit of log(x) as x approaches 0):\n",
      " |      \n",
      " |      >>> e = sin(log(x))\n",
      " |      >>> e.nseries(x, 0, 6)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      PoleError: ...\n",
      " |      ...\n",
      " |      >>> logx = Symbol('logx')\n",
      " |      >>> e.nseries(x, 0, 6, logx=logx)\n",
      " |      sin(logx)\n",
      " |      \n",
      " |      In the following example, the expansion works but gives only an Order term\n",
      " |      unless the ``logx`` parameter is used:\n",
      " |      \n",
      " |      >>> e = x**y\n",
      " |      >>> e.nseries(x, 0, 2)\n",
      " |      O(log(x)**2)\n",
      " |      >>> e.nseries(x, 0, 2, logx=logx)\n",
      " |      exp(logx*y)\n",
      " |  \n",
      " |  nsimplify(self, constants=(), tolerance=None, full=False)\n",
      " |      See the nsimplify function in sympy.simplify\n",
      " |  \n",
      " |  powsimp(self, *args, **kwargs)\n",
      " |      See the powsimp function in sympy.simplify\n",
      " |  \n",
      " |  primitive(self)\n",
      " |      Return the positive Rational that can be extracted non-recursively\n",
      " |      from every term of self (i.e., self is treated like an Add). This is\n",
      " |      like the as_coeff_Mul() method but primitive always extracts a positive\n",
      " |      Rational (never a negative or a Float).\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> (3*(x + 1)**2).primitive()\n",
      " |      (3, (x + 1)**2)\n",
      " |      >>> a = (6*x + 2); a.primitive()\n",
      " |      (2, 3*x + 1)\n",
      " |      >>> b = (x/2 + 3); b.primitive()\n",
      " |      (1/2, x + 6)\n",
      " |      >>> (a*b).primitive() == (1, a*b)\n",
      " |      True\n",
      " |  \n",
      " |  radsimp(self, **kwargs)\n",
      " |      See the radsimp function in sympy.simplify\n",
      " |  \n",
      " |  ratsimp(self)\n",
      " |      See the ratsimp function in sympy.simplify\n",
      " |  \n",
      " |  removeO(self)\n",
      " |      Removes the additive O(..) symbol if there is one\n",
      " |  \n",
      " |  round(self, n=None)\n",
      " |      Return x rounded to the given decimal place.\n",
      " |      \n",
      " |      If a complex number would results, apply round to the real\n",
      " |      and imaginary components of the number.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import pi, E, I, S, Number\n",
      " |      >>> pi.round()\n",
      " |      3\n",
      " |      >>> pi.round(2)\n",
      " |      3.14\n",
      " |      >>> (2*pi + E*I).round()\n",
      " |      6 + 3*I\n",
      " |      \n",
      " |      The round method has a chopping effect:\n",
      " |      \n",
      " |      >>> (2*pi + I/10).round()\n",
      " |      6\n",
      " |      >>> (pi/10 + 2*I).round()\n",
      " |      2*I\n",
      " |      >>> (pi/10 + E*I).round(2)\n",
      " |      0.31 + 2.72*I\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      The Python ``round`` function uses the SymPy ``round`` method so it\n",
      " |      will always return a SymPy number (not a Python float or int):\n",
      " |      \n",
      " |      >>> isinstance(round(S(123), -2), Number)\n",
      " |      True\n",
      " |  \n",
      " |  separate(self, deep=False, force=False)\n",
      " |      See the separate function in sympy.simplify\n",
      " |  \n",
      " |  series(self, x=None, x0=0, n=6, dir='+', logx=None, cdir=0)\n",
      " |      Series expansion of \"self\" around ``x = x0`` yielding either terms of\n",
      " |      the series one by one (the lazy series given when n=None), else\n",
      " |      all the terms at once when n != None.\n",
      " |      \n",
      " |      Returns the series expansion of \"self\" around the point ``x = x0``\n",
      " |      with respect to ``x`` up to ``O((x - x0)**n, x, x0)`` (default n is 6).\n",
      " |      \n",
      " |      If ``x=None`` and ``self`` is univariate, the univariate symbol will\n",
      " |      be supplied, otherwise an error will be raised.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      expr : Expression\n",
      " |             The expression whose series is to be expanded.\n",
      " |      \n",
      " |      x : Symbol\n",
      " |          It is the variable of the expression to be calculated.\n",
      " |      \n",
      " |      x0 : Value\n",
      " |           The value around which ``x`` is calculated. Can be any value\n",
      " |           from ``-oo`` to ``oo``.\n",
      " |      \n",
      " |      n : Value\n",
      " |          The number of terms upto which the series is to be expanded.\n",
      " |      \n",
      " |      dir : String, optional\n",
      " |            The series-expansion can be bi-directional. If ``dir=\"+\"``,\n",
      " |            then (x->x0+). If ``dir=\"-\", then (x->x0-). For infinite\n",
      " |            ``x0`` (``oo`` or ``-oo``), the ``dir`` argument is determined\n",
      " |            from the direction of the infinity (i.e., ``dir=\"-\"`` for\n",
      " |            ``oo``).\n",
      " |      \n",
      " |      logx : optional\n",
      " |             It is used to replace any log(x) in the returned series with a\n",
      " |             symbolic value rather than evaluating the actual value.\n",
      " |      \n",
      " |      cdir : optional\n",
      " |             It stands for complex direction, and indicates the direction\n",
      " |             from which the expansion needs to be evaluated.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cos, exp, tan\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> cos(x).series()\n",
      " |      1 - x**2/2 + x**4/24 + O(x**6)\n",
      " |      >>> cos(x).series(n=4)\n",
      " |      1 - x**2/2 + O(x**4)\n",
      " |      >>> cos(x).series(x, x0=1, n=2)\n",
      " |      cos(1) - (x - 1)*sin(1) + O((x - 1)**2, (x, 1))\n",
      " |      >>> e = cos(x + exp(y))\n",
      " |      >>> e.series(y, n=2)\n",
      " |      cos(x + 1) - y*sin(x + 1) + O(y**2)\n",
      " |      >>> e.series(x, n=2)\n",
      " |      cos(exp(y)) - x*sin(exp(y)) + O(x**2)\n",
      " |      \n",
      " |      If ``n=None`` then a generator of the series terms will be returned.\n",
      " |      \n",
      " |      >>> term=cos(x).series(n=None)\n",
      " |      >>> [next(term) for i in range(2)]\n",
      " |      [1, -x**2/2]\n",
      " |      \n",
      " |      For ``dir=+`` (default) the series is calculated from the right and\n",
      " |      for ``dir=-`` the series from the left. For smooth functions this\n",
      " |      flag will not alter the results.\n",
      " |      \n",
      " |      >>> abs(x).series(dir=\"+\")\n",
      " |      x\n",
      " |      >>> abs(x).series(dir=\"-\")\n",
      " |      -x\n",
      " |      >>> f = tan(x)\n",
      " |      >>> f.series(x, 2, 6, \"+\")\n",
      " |      tan(2) + (1 + tan(2)**2)*(x - 2) + (x - 2)**2*(tan(2)**3 + tan(2)) +\n",
      " |      (x - 2)**3*(1/3 + 4*tan(2)**2/3 + tan(2)**4) + (x - 2)**4*(tan(2)**5 +\n",
      " |      5*tan(2)**3/3 + 2*tan(2)/3) + (x - 2)**5*(2/15 + 17*tan(2)**2/15 +\n",
      " |      2*tan(2)**4 + tan(2)**6) + O((x - 2)**6, (x, 2))\n",
      " |      \n",
      " |      >>> f.series(x, 2, 3, \"-\")\n",
      " |      tan(2) + (2 - x)*(-tan(2)**2 - 1) + (2 - x)**2*(tan(2)**3 + tan(2))\n",
      " |      + O((x - 2)**3, (x, 2))\n",
      " |      \n",
      " |      Returns\n",
      " |      =======\n",
      " |      \n",
      " |      Expr : Expression\n",
      " |          Series expansion of the expression about x0\n",
      " |      \n",
      " |      Raises\n",
      " |      ======\n",
      " |      \n",
      " |      TypeError\n",
      " |          If \"n\" and \"x0\" are infinity objects\n",
      " |      \n",
      " |      PoleError\n",
      " |          If \"x0\" is an infinity object\n",
      " |  \n",
      " |  sort_key(self, order=None)\n",
      " |      Return a sort key.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import S, I\n",
      " |      \n",
      " |      >>> sorted([S(1)/2, I, -I], key=lambda x: x.sort_key())\n",
      " |      [1/2, -I, I]\n",
      " |      \n",
      " |      >>> S(\"[x, 1/x, 1/x**2, x**2, x**(1/2), x**(1/4), x**(3/2)]\")\n",
      " |      [x, 1/x, x**(-2), x**2, sqrt(x), x**(1/4), x**(3/2)]\n",
      " |      >>> sorted(_, key=lambda x: x.sort_key())\n",
      " |      [x**(-2), 1/x, x**(1/4), sqrt(x), x, x**(3/2), x**2]\n",
      " |  \n",
      " |  taylor_term(self, n, x, *previous_terms)\n",
      " |      General method for the taylor term.\n",
      " |      \n",
      " |      This method is slow, because it differentiates n-times. Subclasses can\n",
      " |      redefine it to make it faster by using the \"previous_terms\".\n",
      " |  \n",
      " |  together(self, *args, **kwargs)\n",
      " |      See the together function in sympy.polys\n",
      " |  \n",
      " |  transpose(self)\n",
      " |  \n",
      " |  trigsimp(self, **args)\n",
      " |      See the trigsimp function in sympy.simplify\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.expr.Expr:\n",
      " |  \n",
      " |  expr_free_symbols\n",
      " |      Like ``free_symbols``, but returns the free symbols only if\n",
      " |      they are contained in an expression node.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (x + y).expr_free_symbols # doctest: +SKIP\n",
      " |      {x, y}\n",
      " |      \n",
      " |      If the expression is contained in a non-expression object, do not return\n",
      " |      the free symbols. Compare:\n",
      " |      \n",
      " |      >>> from sympy import Tuple\n",
      " |      >>> t = Tuple(x + y)\n",
      " |      >>> t.expr_free_symbols # doctest: +SKIP\n",
      " |      set()\n",
      " |      >>> t.free_symbols\n",
      " |      {x, y}\n",
      " |  \n",
      " |  is_number\n",
      " |      Returns True if ``self`` has no free symbols and no\n",
      " |      undefined functions (AppliedUndef, to be precise). It will be\n",
      " |      faster than ``if not self.free_symbols``, however, since\n",
      " |      ``is_number`` will fail as soon as it hits a free symbol\n",
      " |      or undefined function.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Function, Integral, cos, sin, pi\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> f = Function('f')\n",
      " |      \n",
      " |      >>> x.is_number\n",
      " |      False\n",
      " |      >>> f(1).is_number\n",
      " |      False\n",
      " |      >>> (2*x).is_number\n",
      " |      False\n",
      " |      >>> (2 + Integral(2, x)).is_number\n",
      " |      False\n",
      " |      >>> (2 + Integral(2, (x, 1, 2))).is_number\n",
      " |      True\n",
      " |      \n",
      " |      Not all numbers are Numbers in the SymPy sense:\n",
      " |      \n",
      " |      >>> pi.is_number, pi.is_Number\n",
      " |      (True, False)\n",
      " |      \n",
      " |      If something is a number it should evaluate to a number with\n",
      " |      real and imaginary parts that are Numbers; the result may not\n",
      " |      be comparable, however, since the real and/or imaginary part\n",
      " |      of the result may not have precision.\n",
      " |      \n",
      " |      >>> cos(1).is_number and cos(1).is_comparable\n",
      " |      True\n",
      " |      \n",
      " |      >>> z = cos(1)**2 + sin(1)**2 - 1\n",
      " |      >>> z.is_number\n",
      " |      True\n",
      " |      >>> z.is_comparable\n",
      " |      False\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      sympy.core.basic.Basic.is_comparable\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.expr.Expr:\n",
      " |  \n",
      " |  is_scalar = True\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __eq__(self, other)\n",
      " |      Return a boolean indicating whether a == b on the basis of\n",
      " |      their symbolic trees.\n",
      " |      \n",
      " |      This is the same as a.compare(b) == 0 but faster.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      If a class that overrides __eq__() needs to retain the\n",
      " |      implementation of __hash__() from a parent class, the\n",
      " |      interpreter must be told this explicitly by setting\n",
      " |      __hash__ : Callable[[object], int] = <ParentClass>.__hash__.\n",
      " |      Otherwise the inheritance of __hash__() will be blocked,\n",
      " |      just as if __hash__ had been explicitly set to None.\n",
      " |      \n",
      " |      References\n",
      " |      ==========\n",
      " |      \n",
      " |      from http://docs.python.org/dev/reference/datamodel.html#object.__hash__\n",
      " |  \n",
      " |  __getnewargs__(self)\n",
      " |  \n",
      " |  __getstate__(self)\n",
      " |  \n",
      " |  __hash__(self) -> int\n",
      " |      Return hash(self).\n",
      " |  \n",
      " |  __ne__(self, other)\n",
      " |      ``a != b``  -> Compare two symbolic trees and see whether they are different\n",
      " |      \n",
      " |      this is the same as:\n",
      " |      \n",
      " |      ``a.compare(b) != 0``\n",
      " |      \n",
      " |      but faster\n",
      " |  \n",
      " |  __reduce_ex__(self, protocol)\n",
      " |      Helper for pickle.\n",
      " |  \n",
      " |  __setstate__(self, state)\n",
      " |  \n",
      " |  as_dummy(self)\n",
      " |      Return the expression with any objects having structurally\n",
      " |      bound symbols replaced with unique, canonical symbols within\n",
      " |      the object in which they appear and having only the default\n",
      " |      assumption for commutativity being True. When applied to a\n",
      " |      symbol a new symbol having only the same commutativity will be\n",
      " |      returned.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> r = Symbol('r', real=True)\n",
      " |      >>> Integral(r, (r, x)).as_dummy()\n",
      " |      Integral(_0, (_0, x))\n",
      " |      >>> _.variables[0].is_real is None\n",
      " |      True\n",
      " |      >>> r.as_dummy()\n",
      " |      _r\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Any object that has structurally bound variables should have\n",
      " |      a property, `bound_symbols` that returns those symbols\n",
      " |      appearing in the object.\n",
      " |  \n",
      " |  atoms(self, *types)\n",
      " |      Returns the atoms that form the current object.\n",
      " |      \n",
      " |      By default, only objects that are truly atomic and cannot\n",
      " |      be divided into smaller pieces are returned: symbols, numbers,\n",
      " |      and number symbols like I and pi. It is possible to request\n",
      " |      atoms of any type, however, as demonstrated below.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import I, pi, sin\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms()\n",
      " |      {1, 2, I, pi, x, y}\n",
      " |      \n",
      " |      If one or more types are given, the results will contain only\n",
      " |      those types of atoms.\n",
      " |      \n",
      " |      >>> from sympy import Number, NumberSymbol, Symbol\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Symbol)\n",
      " |      {x, y}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number)\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol)\n",
      " |      {1, 2, pi}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol, I)\n",
      " |      {1, 2, I, pi}\n",
      " |      \n",
      " |      Note that I (imaginary unit) and zoo (complex infinity) are special\n",
      " |      types of number symbols and are not part of the NumberSymbol class.\n",
      " |      \n",
      " |      The type can be given implicitly, too:\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(x) # x is a Symbol\n",
      " |      {x, y}\n",
      " |      \n",
      " |      Be careful to check your assumptions when using the implicit option\n",
      " |      since ``S(1).is_Integer = True`` but ``type(S(1))`` is ``One``, a special type\n",
      " |      of SymPy atom, while ``type(S(2))`` is type ``Integer`` and will find all\n",
      " |      integers in an expression:\n",
      " |      \n",
      " |      >>> from sympy import S\n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(1))\n",
      " |      {1}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(S(2))\n",
      " |      {1, 2}\n",
      " |      \n",
      " |      Finally, arguments to atoms() can select more than atomic atoms: any\n",
      " |      SymPy type (loaded in core/__init__.py) can be listed as an argument\n",
      " |      and those types of \"atoms\" as found in scanning the arguments of the\n",
      " |      expression recursively:\n",
      " |      \n",
      " |      >>> from sympy import Function, Mul\n",
      " |      >>> from sympy.core.function import AppliedUndef\n",
      " |      >>> f = Function('f')\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(Function)\n",
      " |      {f(x), sin(y + I*pi)}\n",
      " |      >>> (1 + f(x) + 2*sin(y + I*pi)).atoms(AppliedUndef)\n",
      " |      {f(x)}\n",
      " |      \n",
      " |      >>> (1 + x + 2*sin(y + I*pi)).atoms(Mul)\n",
      " |      {I*pi, 2*sin(y + I*pi)}\n",
      " |  \n",
      " |  compare(self, other)\n",
      " |      Return -1, 0, 1 if the object is smaller, equal, or greater than other.\n",
      " |      \n",
      " |      Not in the mathematical sense. If the object is of a different type\n",
      " |      from the \"other\" then their classes are ordered according to\n",
      " |      the sorted_classes list.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> x.compare(y)\n",
      " |      -1\n",
      " |      >>> x.compare(x)\n",
      " |      0\n",
      " |      >>> y.compare(x)\n",
      " |      1\n",
      " |  \n",
      " |  copy(self)\n",
      " |  \n",
      " |  count(self, query)\n",
      " |      Count the number of matching subexpressions.\n",
      " |  \n",
      " |  dummy_eq(self, other, symbol=None)\n",
      " |      Compare two expressions and handle dummy symbols.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Dummy\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> u = Dummy('u')\n",
      " |      \n",
      " |      >>> (u**2 + 1).dummy_eq(x**2 + 1)\n",
      " |      True\n",
      " |      >>> (u**2 + 1) == (x**2 + 1)\n",
      " |      False\n",
      " |      \n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, x)\n",
      " |      True\n",
      " |      >>> (u**2 + y).dummy_eq(x**2 + y, y)\n",
      " |      False\n",
      " |  \n",
      " |  find(self, query, group=False)\n",
      " |      Find all subexpressions matching a query.\n",
      " |  \n",
      " |  has(self, *patterns)\n",
      " |      Test whether any subexpression matches any of the patterns.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import sin\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x**2 + sin(x*y)).has(z)\n",
      " |      False\n",
      " |      >>> (x**2 + sin(x*y)).has(x, y, z)\n",
      " |      True\n",
      " |      >>> x.has(x)\n",
      " |      True\n",
      " |      \n",
      " |      Note ``has`` is a structural algorithm with no knowledge of\n",
      " |      mathematics. Consider the following half-open interval:\n",
      " |      \n",
      " |      >>> from sympy import Interval\n",
      " |      >>> i = Interval.Lopen(0, 5); i\n",
      " |      Interval.Lopen(0, 5)\n",
      " |      >>> i.args\n",
      " |      (0, 5, True, False)\n",
      " |      >>> i.has(4)  # there is no \"4\" in the arguments\n",
      " |      False\n",
      " |      >>> i.has(0)  # there *is* a \"0\" in the arguments\n",
      " |      True\n",
      " |      \n",
      " |      Instead, use ``contains`` to determine whether a number is in the\n",
      " |      interval or not:\n",
      " |      \n",
      " |      >>> i.contains(4)\n",
      " |      True\n",
      " |      >>> i.contains(0)\n",
      " |      False\n",
      " |      \n",
      " |      \n",
      " |      Note that ``expr.has(*patterns)`` is exactly equivalent to\n",
      " |      ``any(expr.has(p) for p in patterns)``. In particular, ``False`` is\n",
      " |      returned when the list of patterns is empty.\n",
      " |      \n",
      " |      >>> x.has()\n",
      " |      False\n",
      " |  \n",
      " |  has_free(self, *patterns)\n",
      " |      return True if self has object(s) ``x`` as a free expression\n",
      " |      else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Integral, Function\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = Function('f')\n",
      " |      >>> g = Function('g')\n",
      " |      >>> expr = Integral(f(x), (f(x), 1, g(y)))\n",
      " |      >>> expr.free_symbols\n",
      " |      {y}\n",
      " |      >>> expr.has_free(g(y))\n",
      " |      True\n",
      " |      >>> expr.has_free(*(x, f(x)))\n",
      " |      False\n",
      " |      \n",
      " |      This works for subexpressions and types, too:\n",
      " |      \n",
      " |      >>> expr.has_free(g)\n",
      " |      True\n",
      " |      >>> (x + y + 1).has_free(y + 1)\n",
      " |      True\n",
      " |  \n",
      " |  is_hypergeometric(self, k)\n",
      " |  \n",
      " |  match(self, pattern, old=False)\n",
      " |      Pattern matching.\n",
      " |      \n",
      " |      Wild symbols match all.\n",
      " |      \n",
      " |      Return ``None`` when expression (self) does not match\n",
      " |      with pattern. Otherwise return a dictionary such that::\n",
      " |      \n",
      " |        pattern.xreplace(self.match(pattern)) == self\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Wild, Sum\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> p = Wild(\"p\")\n",
      " |      >>> q = Wild(\"q\")\n",
      " |      >>> r = Wild(\"r\")\n",
      " |      >>> e = (x+y)**(x+y)\n",
      " |      >>> e.match(p**p)\n",
      " |      {p_: x + y}\n",
      " |      >>> e.match(p**q)\n",
      " |      {p_: x + y, q_: x + y}\n",
      " |      >>> e = (2*x)**2\n",
      " |      >>> e.match(p*q**r)\n",
      " |      {p_: 4, q_: x, r_: 2}\n",
      " |      >>> (p*q**r).xreplace(e.match(p*q**r))\n",
      " |      4*x**2\n",
      " |      \n",
      " |      Structurally bound symbols are ignored during matching:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(y, (y, 1, p)))\n",
      " |      {p_: 2}\n",
      " |      \n",
      " |      But they can be identified if desired:\n",
      " |      \n",
      " |      >>> Sum(x, (x, 1, 2)).match(Sum(q, (q, 1, p)))\n",
      " |      {p_: 2, q_: x}\n",
      " |      \n",
      " |      The ``old`` flag will give the old-style pattern matching where\n",
      " |      expressions and patterns are essentially solved to give the\n",
      " |      match. Both of the following give None unless ``old=True``:\n",
      " |      \n",
      " |      >>> (x - 2).match(p - x, old=True)\n",
      " |      {p_: 2*x - 2}\n",
      " |      >>> (2/x).match(p*x, old=True)\n",
      " |      {p_: 2/x**2}\n",
      " |  \n",
      " |  matches(self, expr, repl_dict=None, old=False)\n",
      " |      Helper method for match() that looks for a match between Wild symbols\n",
      " |      in self and expressions in expr.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import symbols, Wild, Basic\n",
      " |      >>> a, b, c = symbols('a b c')\n",
      " |      >>> x = Wild('x')\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b, c)) is None\n",
      " |      True\n",
      " |      >>> Basic(a + x, x).matches(Basic(a + b + c, b + c))\n",
      " |      {x_: b + c}\n",
      " |  \n",
      " |  rcall(self, *args)\n",
      " |      Apply on the argument recursively through the expression tree.\n",
      " |      \n",
      " |      This method is used to simulate a common abuse of notation for\n",
      " |      operators. For instance, in SymPy the following will not work:\n",
      " |      \n",
      " |      ``(x+Lambda(y, 2*y))(z) == x+2*z``,\n",
      " |      \n",
      " |      however, you can use:\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> (x + Lambda(y, 2*y)).rcall(z)\n",
      " |      x + 2*z\n",
      " |  \n",
      " |  refine(self, assumption=True)\n",
      " |      See the refine function in sympy.assumptions\n",
      " |  \n",
      " |  replace(self, query, value, map=False, simultaneous=True, exact=None)\n",
      " |      Replace matching subexpressions of ``self`` with ``value``.\n",
      " |      \n",
      " |      If ``map = True`` then also return the mapping {old: new} where ``old``\n",
      " |      was a sub-expression found with query and ``new`` is the replacement\n",
      " |      value for it. If the expression itself doesn't match the query, then\n",
      " |      the returned value will be ``self.xreplace(map)`` otherwise it should\n",
      " |      be ``self.subs(ordered(map.items()))``.\n",
      " |      \n",
      " |      Traverses an expression tree and performs replacement of matching\n",
      " |      subexpressions from the bottom to the top of the tree. The default\n",
      " |      approach is to do the replacement in a simultaneous fashion so\n",
      " |      changes made are targeted only once. If this is not desired or causes\n",
      " |      problems, ``simultaneous`` can be set to False.\n",
      " |      \n",
      " |      In addition, if an expression containing more than one Wild symbol\n",
      " |      is being used to match subexpressions and the ``exact`` flag is None\n",
      " |      it will be set to True so the match will only succeed if all non-zero\n",
      " |      values are received for each Wild that appears in the match pattern.\n",
      " |      Setting this to False accepts a match of 0; while setting it True\n",
      " |      accepts all matches that have a 0 in them. See example below for\n",
      " |      cautions.\n",
      " |      \n",
      " |      The list of possible combinations of queries and replacement values\n",
      " |      is listed below:\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      Initial setup\n",
      " |      \n",
      " |      >>> from sympy import log, sin, cos, tan, Wild, Mul, Add\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> f = log(sin(x)) + tan(sin(x**2))\n",
      " |      \n",
      " |      1.1. type -> type\n",
      " |          obj.replace(type, newtype)\n",
      " |      \n",
      " |          When object of type ``type`` is found, replace it with the\n",
      " |          result of passing its argument(s) to ``newtype``.\n",
      " |      \n",
      " |          >>> f.replace(sin, cos)\n",
      " |          log(cos(x)) + tan(cos(x**2))\n",
      " |          >>> sin(x).replace(sin, cos, map=True)\n",
      " |          (cos(x), {sin(x): cos(x)})\n",
      " |          >>> (x*y).replace(Mul, Add)\n",
      " |          x + y\n",
      " |      \n",
      " |      1.2. type -> func\n",
      " |          obj.replace(type, func)\n",
      " |      \n",
      " |          When object of type ``type`` is found, apply ``func`` to its\n",
      " |          argument(s). ``func`` must be written to handle the number\n",
      " |          of arguments of ``type``.\n",
      " |      \n",
      " |          >>> f.replace(sin, lambda arg: sin(2*arg))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |          >>> (x*y).replace(Mul, lambda *args: sin(2*Mul(*args)))\n",
      " |          sin(2*x*y)\n",
      " |      \n",
      " |      2.1. pattern -> expr\n",
      " |          obj.replace(pattern(wild), expr(wild))\n",
      " |      \n",
      " |          Replace subexpressions matching ``pattern`` with the expression\n",
      " |          written in terms of the Wild symbols in ``pattern``.\n",
      " |      \n",
      " |          >>> a, b = map(Wild, 'ab')\n",
      " |          >>> f.replace(sin(a), tan(a))\n",
      " |          log(tan(x)) + tan(tan(x**2))\n",
      " |          >>> f.replace(sin(a), tan(a/2))\n",
      " |          log(tan(x/2)) + tan(tan(x**2/2))\n",
      " |          >>> f.replace(sin(a), a)\n",
      " |          log(x) + tan(x**2)\n",
      " |          >>> (x*y).replace(a*x, a)\n",
      " |          y\n",
      " |      \n",
      " |          Matching is exact by default when more than one Wild symbol\n",
      " |          is used: matching fails unless the match gives non-zero\n",
      " |          values for all Wild symbols:\n",
      " |      \n",
      " |          >>> (2*x + y).replace(a*x + b, b - a)\n",
      " |          y - 2\n",
      " |          >>> (2*x).replace(a*x + b, b - a)\n",
      " |          2*x\n",
      " |      \n",
      " |          When set to False, the results may be non-intuitive:\n",
      " |      \n",
      " |          >>> (2*x).replace(a*x + b, b - a, exact=False)\n",
      " |          2/x\n",
      " |      \n",
      " |      2.2. pattern -> func\n",
      " |          obj.replace(pattern(wild), lambda wild: expr(wild))\n",
      " |      \n",
      " |          All behavior is the same as in 2.1 but now a function in terms of\n",
      " |          pattern variables is used rather than an expression:\n",
      " |      \n",
      " |          >>> f.replace(sin(a), lambda a: sin(2*a))\n",
      " |          log(sin(2*x)) + tan(sin(2*x**2))\n",
      " |      \n",
      " |      3.1. func -> func\n",
      " |          obj.replace(filter, func)\n",
      " |      \n",
      " |          Replace subexpression ``e`` with ``func(e)`` if ``filter(e)``\n",
      " |          is True.\n",
      " |      \n",
      " |          >>> g = 2*sin(x**3)\n",
      " |          >>> g.replace(lambda expr: expr.is_Number, lambda expr: expr**2)\n",
      " |          4*sin(x**9)\n",
      " |      \n",
      " |      The expression itself is also targeted by the query but is done in\n",
      " |      such a fashion that changes are not made twice.\n",
      " |      \n",
      " |          >>> e = x*(x*y + 1)\n",
      " |          >>> e.replace(lambda x: x.is_Mul, lambda x: 2*x)\n",
      " |          2*x*(2*x*y + 1)\n",
      " |      \n",
      " |      When matching a single symbol, `exact` will default to True, but\n",
      " |      this may or may not be the behavior that is desired:\n",
      " |      \n",
      " |      Here, we want `exact=False`:\n",
      " |      \n",
      " |      >>> from sympy import Function\n",
      " |      >>> f = Function('f')\n",
      " |      >>> e = f(1) + f(0)\n",
      " |      >>> q = f(a), lambda a: f(a + 1)\n",
      " |      >>> e.replace(*q, exact=False)\n",
      " |      f(1) + f(2)\n",
      " |      >>> e.replace(*q, exact=True)\n",
      " |      f(0) + f(2)\n",
      " |      \n",
      " |      But here, the nature of matching makes selecting\n",
      " |      the right setting tricky:\n",
      " |      \n",
      " |      >>> e = x**(1 + y)\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**(1 + y)).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(-x - y + 1)\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=False)\n",
      " |      x\n",
      " |      >>> (x**y).replace(x**(1 + a), lambda a: x**-a, exact=True)\n",
      " |      x**(1 - y)\n",
      " |      \n",
      " |      It is probably better to use a different form of the query\n",
      " |      that describes the target expression more precisely:\n",
      " |      \n",
      " |      >>> (1 + x**(1 + y)).replace(\n",
      " |      ... lambda x: x.is_Pow and x.exp.is_Add and x.exp.args[0] == 1,\n",
      " |      ... lambda x: x.base**(1 - (x.exp - 1)))\n",
      " |      ...\n",
      " |      x**(1 - y) + 1\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      \n",
      " |      subs: substitution of subexpressions as defined by the objects\n",
      " |            themselves.\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |  \n",
      " |  rewrite(self, *args, deep=True, **hints)\n",
      " |      Rewrite *self* using a defined rule.\n",
      " |      \n",
      " |      Rewriting transforms an expression to another, which is mathematically\n",
      " |      equivalent but structurally different. For example you can rewrite\n",
      " |      trigonometric functions as complex exponentials or combinatorial\n",
      " |      functions as gamma function.\n",
      " |      \n",
      " |      This method takes a *pattern* and a *rule* as positional arguments.\n",
      " |      *pattern* is optional parameter which defines the types of expressions\n",
      " |      that will be transformed. If it is not passed, all possible expressions\n",
      " |      will be rewritten. *rule* defines how the expression will be rewritten.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      args : *rule*, or *pattern* and *rule*.\n",
      " |          - *pattern* is a type or an iterable of types.\n",
      " |          - *rule* can be any object.\n",
      " |      \n",
      " |      deep : bool, optional.\n",
      " |          If ``True``, subexpressions are recursively transformed. Default is\n",
      " |          ``True``.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      If *pattern* is unspecified, all possible expressions are transformed.\n",
      " |      \n",
      " |      >>> from sympy import cos, sin, exp, I\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> expr = cos(x) + I*sin(x)\n",
      " |      >>> expr.rewrite(exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Pattern can be a type or an iterable of types.\n",
      " |      \n",
      " |      >>> expr.rewrite(sin, exp)\n",
      " |      exp(I*x)/2 + cos(x) - exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos,], exp)\n",
      " |      exp(I*x)/2 + I*sin(x) + exp(-I*x)/2\n",
      " |      >>> expr.rewrite([cos, sin], exp)\n",
      " |      exp(I*x)\n",
      " |      \n",
      " |      Rewriting behavior can be implemented by defining ``_eval_rewrite()``\n",
      " |      method.\n",
      " |      \n",
      " |      >>> from sympy import Expr, sqrt, pi\n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite(self, rule, args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         if rule == cos:\n",
      " |      ...             return cos(pi/2 - x, evaluate=False)\n",
      " |      ...         if rule == sqrt:\n",
      " |      ...             return sqrt(1 - cos(x)**2)\n",
      " |      >>> MySin(MySin(x)).rewrite(cos)\n",
      " |      cos(-cos(-x + pi/2) + pi/2)\n",
      " |      >>> MySin(x).rewrite(sqrt)\n",
      " |      sqrt(1 - cos(x)**2)\n",
      " |      \n",
      " |      Defining ``_eval_rewrite_as_[...]()`` method is supported for backwards\n",
      " |      compatibility reason. This may be removed in the future and using it is\n",
      " |      discouraged.\n",
      " |      \n",
      " |      >>> class MySin(Expr):\n",
      " |      ...     def _eval_rewrite_as_cos(self, *args, **hints):\n",
      " |      ...         x, = args\n",
      " |      ...         return cos(pi/2 - x, evaluate=False)\n",
      " |      >>> MySin(x).rewrite(cos)\n",
      " |      cos(-x + pi/2)\n",
      " |  \n",
      " |  simplify(self, **kwargs)\n",
      " |      See the simplify function in sympy.simplify\n",
      " |  \n",
      " |  subs(self, *args, **kwargs)\n",
      " |      Substitutes old for new in an expression after sympifying args.\n",
      " |      \n",
      " |      `args` is either:\n",
      " |        - two arguments, e.g. foo.subs(old, new)\n",
      " |        - one iterable argument, e.g. foo.subs(iterable). The iterable may be\n",
      " |           o an iterable container with (old, new) pairs. In this case the\n",
      " |             replacements are processed in the order given with successive\n",
      " |             patterns possibly affecting replacements already made.\n",
      " |           o a dict or set whose key/value items correspond to old/new pairs.\n",
      " |             In this case the old/new pairs will be sorted by op count and in\n",
      " |             case of a tie, by number of args and the default_sort_key. The\n",
      " |             resulting sorted list is then processed as an iterable container\n",
      " |             (see previous).\n",
      " |      \n",
      " |      If the keyword ``simultaneous`` is True, the subexpressions will not be\n",
      " |      evaluated until all the substitutions have been made.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import pi, exp, limit, oo\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      >>> (1 + x*y).subs(x, pi)\n",
      " |      pi*y + 1\n",
      " |      >>> (1 + x*y).subs({x:pi, y:2})\n",
      " |      1 + 2*pi\n",
      " |      >>> (1 + x*y).subs([(x, pi), (y, 2)])\n",
      " |      1 + 2*pi\n",
      " |      >>> reps = [(y, x**2), (x, 2)]\n",
      " |      >>> (x + y).subs(reps)\n",
      " |      6\n",
      " |      >>> (x + y).subs(reversed(reps))\n",
      " |      x**2 + 2\n",
      " |      \n",
      " |      >>> (x**2 + x**4).subs(x**2, y)\n",
      " |      y**2 + y\n",
      " |      \n",
      " |      To replace only the x**2 but not the x**4, use xreplace:\n",
      " |      \n",
      " |      >>> (x**2 + x**4).xreplace({x**2: y})\n",
      " |      x**4 + y\n",
      " |      \n",
      " |      To delay evaluation until all substitutions have been made,\n",
      " |      set the keyword ``simultaneous`` to True:\n",
      " |      \n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)])\n",
      " |      0\n",
      " |      >>> (x/y).subs([(x, 0), (y, 0)], simultaneous=True)\n",
      " |      nan\n",
      " |      \n",
      " |      This has the added feature of not allowing subsequent substitutions\n",
      " |      to affect those already made:\n",
      " |      \n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y})\n",
      " |      1\n",
      " |      >>> ((x + y)/y).subs({x + y: y, y: x + y}, simultaneous=True)\n",
      " |      y/(x + y)\n",
      " |      \n",
      " |      In order to obtain a canonical result, unordered iterables are\n",
      " |      sorted by count_op length, number of arguments and by the\n",
      " |      default_sort_key to break any ties. All other iterables are left\n",
      " |      unsorted.\n",
      " |      \n",
      " |      >>> from sympy import sqrt, sin, cos\n",
      " |      >>> from sympy.abc import a, b, c, d, e\n",
      " |      \n",
      " |      >>> A = (sqrt(sin(2*x)), a)\n",
      " |      >>> B = (sin(2*x), b)\n",
      " |      >>> C = (cos(2*x), c)\n",
      " |      >>> D = (x, d)\n",
      " |      >>> E = (exp(x), e)\n",
      " |      \n",
      " |      >>> expr = sqrt(sin(2*x))*sin(exp(x)*x)*cos(2*x) + sin(2*x)\n",
      " |      \n",
      " |      >>> expr.subs(dict([A, B, C, D, E]))\n",
      " |      a*c*sin(d*e) + b\n",
      " |      \n",
      " |      The resulting expression represents a literal replacement of the\n",
      " |      old arguments with the new arguments. This may not reflect the\n",
      " |      limiting behavior of the expression:\n",
      " |      \n",
      " |      >>> (x**3 - 3*x).subs({x: oo})\n",
      " |      nan\n",
      " |      \n",
      " |      >>> limit(x**3 - 3*x, x, oo)\n",
      " |      oo\n",
      " |      \n",
      " |      If the substitution will be followed by numerical\n",
      " |      evaluation, it is better to pass the substitution to\n",
      " |      evalf as\n",
      " |      \n",
      " |      >>> (1/x).evalf(subs={x: 3.0}, n=21)\n",
      " |      0.333333333333333333333\n",
      " |      \n",
      " |      rather than\n",
      " |      \n",
      " |      >>> (1/x).subs({x: 3.0}).evalf(21)\n",
      " |      0.333333333333333314830\n",
      " |      \n",
      " |      as the former will ensure that the desired level of precision is\n",
      " |      obtained.\n",
      " |      \n",
      " |      See Also\n",
      " |      ========\n",
      " |      replace: replacement capable of doing wildcard-like matching,\n",
      " |               parsing of match, and conditional replacements\n",
      " |      xreplace: exact node replacement in expr tree; also capable of\n",
      " |                using matching rules\n",
      " |      sympy.core.evalf.EvalfMixin.evalf: calculates the given formula to a desired level of precision\n",
      " |  \n",
      " |  xreplace lambda rule, **_\n",
      " |      # Function needs args so we define a property that returns\n",
      " |      # a function that takes args...and then use that function\n",
      " |      # to return the right value\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  fromiter(args, **assumptions) from sympy.core.function.FunctionClass\n",
      " |      Create a new object from an iterable.\n",
      " |      \n",
      " |      This is a convenience function that allows one to create objects from\n",
      " |      any iterable, without having to convert to a list or tuple first.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Tuple\n",
      " |      >>> Tuple.fromiter(i for i in range(5))\n",
      " |      (0, 1, 2, 3, 4)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Readonly properties inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  args\n",
      " |      Returns a tuple of arguments of 'self'.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import cot\n",
      " |      >>> from sympy.abc import x, y\n",
      " |      \n",
      " |      >>> cot(x).args\n",
      " |      (x,)\n",
      " |      \n",
      " |      >>> cot(x).args[0]\n",
      " |      x\n",
      " |      \n",
      " |      >>> (x*y).args\n",
      " |      (x, y)\n",
      " |      \n",
      " |      >>> (x*y).args[1]\n",
      " |      y\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      Never use self._args, always use self.args.\n",
      " |      Only use _args in __new__ when creating a new function.\n",
      " |      Don't override .args() from Basic (so that it's easy to\n",
      " |      change the interface in the future if needed).\n",
      " |  \n",
      " |  assumptions0\n",
      " |      Return object `type` assumptions.\n",
      " |      \n",
      " |      For example:\n",
      " |      \n",
      " |        Symbol('x', real=True)\n",
      " |        Symbol('x', integer=True)\n",
      " |      \n",
      " |      are different objects. In other words, besides Python type (Symbol in\n",
      " |      this case), the initial assumptions are also forming their typeinfo.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Symbol\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True}\n",
      " |      >>> x = Symbol(\"x\", positive=True)\n",
      " |      >>> x.assumptions0\n",
      " |      {'commutative': True, 'complex': True, 'extended_negative': False,\n",
      " |       'extended_nonnegative': True, 'extended_nonpositive': False,\n",
      " |       'extended_nonzero': True, 'extended_positive': True, 'extended_real':\n",
      " |       True, 'finite': True, 'hermitian': True, 'imaginary': False,\n",
      " |       'infinite': False, 'negative': False, 'nonnegative': True,\n",
      " |       'nonpositive': False, 'nonzero': True, 'positive': True, 'real':\n",
      " |       True, 'zero': False}\n",
      " |  \n",
      " |  canonical_variables\n",
      " |      Return a dictionary mapping any variable defined in\n",
      " |      ``self.bound_symbols`` to Symbols that do not clash\n",
      " |      with any free symbols in the expression.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import Lambda\n",
      " |      >>> from sympy.abc import x\n",
      " |      >>> Lambda(x, 2*x).canonical_variables\n",
      " |      {x: _0}\n",
      " |  \n",
      " |  free_symbols\n",
      " |      Return from the atoms of self those which are free symbols.\n",
      " |      \n",
      " |      For most expressions, all symbols are free symbols. For some classes\n",
      " |      this is not true. e.g. Integrals use Symbols for the dummy variables\n",
      " |      which are bound variables, so Integral has a method to return all\n",
      " |      symbols except those. Derivative keeps track of symbols with respect\n",
      " |      to which it will perform a derivative; those are\n",
      " |      bound variables, too, so it has its own free_symbols method.\n",
      " |      \n",
      " |      Any other method that uses bound variables should implement a\n",
      " |      free_symbols method.\n",
      " |  \n",
      " |  is_algebraic\n",
      " |  \n",
      " |  is_antihermitian\n",
      " |  \n",
      " |  is_commutative\n",
      " |  \n",
      " |  is_comparable\n",
      " |      Return True if self can be computed to a real number\n",
      " |      (or already is a real number) with precision, else False.\n",
      " |      \n",
      " |      Examples\n",
      " |      ========\n",
      " |      \n",
      " |      >>> from sympy import exp_polar, pi, I\n",
      " |      >>> (I*exp_polar(I*pi/2)).is_comparable\n",
      " |      True\n",
      " |      >>> (I*exp_polar(I*pi*2)).is_comparable\n",
      " |      False\n",
      " |      \n",
      " |      A False result does not mean that `self` cannot be rewritten\n",
      " |      into a form that would be comparable. For example, the\n",
      " |      difference computed below is zero but without simplification\n",
      " |      it does not evaluate to a zero with precision:\n",
      " |      \n",
      " |      >>> e = 2**pi*(1 + 2**pi)\n",
      " |      >>> dif = e - e.expand()\n",
      " |      >>> dif.is_comparable\n",
      " |      False\n",
      " |      >>> dif.n(2)._prec\n",
      " |      1\n",
      " |  \n",
      " |  is_complex\n",
      " |  \n",
      " |  is_composite\n",
      " |  \n",
      " |  is_even\n",
      " |  \n",
      " |  is_extended_negative\n",
      " |  \n",
      " |  is_extended_nonnegative\n",
      " |  \n",
      " |  is_extended_nonpositive\n",
      " |  \n",
      " |  is_extended_nonzero\n",
      " |  \n",
      " |  is_extended_positive\n",
      " |  \n",
      " |  is_extended_real\n",
      " |  \n",
      " |  is_finite\n",
      " |  \n",
      " |  is_hermitian\n",
      " |  \n",
      " |  is_imaginary\n",
      " |  \n",
      " |  is_infinite\n",
      " |  \n",
      " |  is_integer\n",
      " |  \n",
      " |  is_irrational\n",
      " |  \n",
      " |  is_negative\n",
      " |  \n",
      " |  is_noninteger\n",
      " |  \n",
      " |  is_nonnegative\n",
      " |  \n",
      " |  is_nonpositive\n",
      " |  \n",
      " |  is_nonzero\n",
      " |  \n",
      " |  is_odd\n",
      " |  \n",
      " |  is_polar\n",
      " |  \n",
      " |  is_positive\n",
      " |  \n",
      " |  is_prime\n",
      " |  \n",
      " |  is_rational\n",
      " |  \n",
      " |  is_real\n",
      " |  \n",
      " |  is_transcendental\n",
      " |  \n",
      " |  is_zero\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes inherited from sympy.core.basic.Basic:\n",
      " |  \n",
      " |  __annotations__ = {'_args': 'Tuple[Basic, ...]', '_mhash': 'Any', 'kin...\n",
      " |  \n",
      " |  is_Add = False\n",
      " |  \n",
      " |  is_AlgebraicNumber = False\n",
      " |  \n",
      " |  is_Atom = False\n",
      " |  \n",
      " |  is_Boolean = False\n",
      " |  \n",
      " |  is_Derivative = False\n",
      " |  \n",
      " |  is_Dummy = False\n",
      " |  \n",
      " |  is_Equality = False\n",
      " |  \n",
      " |  is_Float = False\n",
      " |  \n",
      " |  is_Indexed = False\n",
      " |  \n",
      " |  is_Integer = False\n",
      " |  \n",
      " |  is_MatAdd = False\n",
      " |  \n",
      " |  is_MatMul = False\n",
      " |  \n",
      " |  is_Matrix = False\n",
      " |  \n",
      " |  is_Mul = False\n",
      " |  \n",
      " |  is_Not = False\n",
      " |  \n",
      " |  is_Number = False\n",
      " |  \n",
      " |  is_NumberSymbol = False\n",
      " |  \n",
      " |  is_Order = False\n",
      " |  \n",
      " |  is_Point = False\n",
      " |  \n",
      " |  is_Poly = False\n",
      " |  \n",
      " |  is_Pow = False\n",
      " |  \n",
      " |  is_Rational = False\n",
      " |  \n",
      " |  is_Relational = False\n",
      " |  \n",
      " |  is_Symbol = False\n",
      " |  \n",
      " |  is_Vector = False\n",
      " |  \n",
      " |  is_Wild = False\n",
      " |  \n",
      " |  is_symbol = False\n",
      " |  \n",
      " |  kind = UndefinedKind\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.printing.defaults.Printable:\n",
      " |  \n",
      " |  __repr__ = __str__(self)\n",
      " |  \n",
      " |  __str__(self)\n",
      " |      Return str(self).\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from sympy.core.evalf.EvalfMixin:\n",
      " |  \n",
      " |  evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      " |      Evaluate the given formula to an accuracy of *n* digits.\n",
      " |      \n",
      " |      Parameters\n",
      " |      ==========\n",
      " |      \n",
      " |      subs : dict, optional\n",
      " |          Substitute numerical values for symbols, e.g.\n",
      " |          ``subs={x:3, y:1+pi}``. The substitutions must be given as a\n",
      " |          dictionary.\n",
      " |      \n",
      " |      maxn : int, optional\n",
      " |          Allow a maximum temporary working precision of maxn digits.\n",
      " |      \n",
      " |      chop : bool or number, optional\n",
      " |          Specifies how to replace tiny real or imaginary parts in\n",
      " |          subresults by exact zeros.\n",
      " |      \n",
      " |          When ``True`` the chop value defaults to standard precision.\n",
      " |      \n",
      " |          Otherwise the chop value is used to determine the\n",
      " |          magnitude of \"small\" for purposes of chopping.\n",
      " |      \n",
      " |          >>> from sympy import N\n",
      " |          >>> x = 1e-4\n",
      " |          >>> N(x, chop=True)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-5)\n",
      " |          0.000100000000000000\n",
      " |          >>> N(x, chop=1e-4)\n",
      " |          0\n",
      " |      \n",
      " |      strict : bool, optional\n",
      " |          Raise ``PrecisionExhausted`` if any subresult fails to\n",
      " |          evaluate to full accuracy, given the available maxprec.\n",
      " |      \n",
      " |      quad : str, optional\n",
      " |          Choose algorithm for numerical quadrature. By default,\n",
      " |          tanh-sinh quadrature is used. For oscillatory\n",
      " |          integrals on an infinite interval, try ``quad='osc'``.\n",
      " |      \n",
      " |      verbose : bool, optional\n",
      " |          Print debug information.\n",
      " |      \n",
      " |      Notes\n",
      " |      =====\n",
      " |      \n",
      " |      When Floats are naively substituted into an expression,\n",
      " |      precision errors may adversely affect the result. For example,\n",
      " |      adding 1e16 (a Float) to 1 will truncate to 1e16; if 1e16 is\n",
      " |      then subtracted, the result will be 0.\n",
      " |      That is exactly what happens in the following:\n",
      " |      \n",
      " |      >>> from sympy.abc import x, y, z\n",
      " |      >>> values = {x: 1e16, y: 1, z: 1e16}\n",
      " |      >>> (x + y - z).subs(values)\n",
      " |      0\n",
      " |      \n",
      " |      Using the subs argument for evalf is the accurate way to\n",
      " |      evaluate such an expression:\n",
      " |      \n",
      " |      >>> (x + y - z).evalf(subs=values)\n",
      " |      1.00000000000000\n",
      " |  \n",
      " |  n = evalf(self, n=15, subs=None, maxn=100, chop=False, strict=False, quad=None, verbose=False)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(Piecewise)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "4badeadb",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=Piecewise((-x**2+2,x<=1),(x+1/x-1,True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6df98813",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{37}{28}$"
      ],
      "text/plain": [
       "37/28"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,expr.subs(x,Rational(1,2)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "a5051562",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left(-\\infty, 2\\right]$"
      ],
      "text/plain": [
       "Interval(-oo, 2)"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_range(-x**2+2,x,Interval.Lopen(-oo,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "08d38463",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left(1, \\infty\\right)$"
      ],
      "text/plain": [
       "Interval.open(1, oo)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_range(x+1/x-1,x,Interval.open(1,oo))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "a9056e84",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - x^{2} + \\left|{2 x - 1}\\right|$"
      ],
      "text/plain": [
       "-x**2 + Abs(2*x - 1)"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=abs(2*x-1)-x**2\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "2c569733",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 2$"
      ],
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "34835593",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\begin{cases} - x^{2} + 2 x & \\text{for}\\: x > 0 \\\\3 x + 6 & \\text{otherwise} \\end{cases}$"
      ],
      "text/plain": [
       "Piecewise((-x**2 + 2*x, x > 0), (3*x + 6, True))"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=Piecewise((-x**2+2*x,x>0),(3*x+6,True))\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "6bbff112",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[- \\frac{3}{2}, 1\\right]$"
      ],
      "text/plain": [
       "Interval(-3/2, 1)"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(expr>=abs(x),x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "3c46999c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\emptyset$"
      ],
      "text/plain": [
       "EmptySet"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(-x**2+1>=(x-2)**2,x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "19868c33",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{2 - \\sqrt{3}, \\sqrt{3} + 2\\right\\}$"
      ],
      "text/plain": [
       "{2 - sqrt(3), sqrt(3) + 2}"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(2*x/(1+x)**2-Rational(1,3),x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "71cd4f7a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{\\sqrt{3}}{3}$"
      ],
      "text/plain": [
       "sqrt(3)/3"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify((2*x/(1-x**2)).subs(x,2-sqrt(3)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "da0bc32e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x^{2} + 3 y^{2} = a^{2}$"
      ],
      "text/plain": [
       "Eq(x**2 + 3*y**2, a**2)"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eq=Eq(x**2+3*y**2,a**2)\n",
    "eq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "3f139f16",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - a^{2} + 6 k m x + 3 m^{2} + x^{2} \\cdot \\left(3 k^{2} + 1\\right)$"
      ],
      "text/plain": [
       "-a**2 + 6*k*m*x + 3*m**2 + x**2*(3*k**2 + 1)"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "collect(expand(eq.subs(y,k*x+m).lhs-eq.subs(y,k*x+m).rhs),x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "9a248733",
   "metadata": {},
   "outputs": [],
   "source": [
    "def quadratic_equation_delt(eq,var):\n",
    "    # first we should check if eq is quadratic equation\n",
    "    # not complement yet\n",
    "    expr=simplify(eq.lhs-eq.rhs)\n",
    "    sums=expr.subs(x,1)\n",
    "    c=simplify(expr.subs(x,0))\n",
    "    b=simplify((sums-expr.subs(x,-1))/2)\n",
    "    a=sums-b-c\n",
    "    return simplify(b**2-4*a*c)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "4ae9538b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 12 a^{2} k^{2} + 4 a^{2} - 12 m^{2}$"
      ],
      "text/plain": [
       "12*a**2*k**2 + 4*a**2 - 12*m**2"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "quadratic_equation_delt(eq.subs(y,k*x+m),x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "9ae1299c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - 8 x^{3} + 12 x^{2} - 6 x + 1$"
      ],
      "text/plain": [
       "-8*x**3 + 12*x**2 - 6*x + 1"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand((1-2*x)**3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "fd861ed6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x^{\\frac{5}{2}} + 15 + \\frac{270}{x^{5}} + \\frac{243}{x^{10}} + \\frac{90}{x^{\\frac{5}{2}}} + \\frac{405}{x^{\\frac{15}{2}}}$"
      ],
      "text/plain": [
       "x**(5/2) + 15 + 270/x**5 + 243/x**10 + 90/x**(5/2) + 405/x**(15/2)"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand((sqrt(x)+3/x**2)**5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "ee1e849d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\log{\\left(x^{2} - 3 x - 4 \\right)}$"
      ],
      "text/plain": [
       "log(x**2 - 3*x - 4)"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=ln(x**2-3*x-4)\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "e11c347e",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "Invalid comparison of non-real zoo",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[0;32mIn [67]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mfunction_monotonyset\u001b[49m\u001b[43m(\u001b[49m\u001b[43mexpr\u001b[49m\u001b[43m,\u001b[49m\u001b[43mx\u001b[49m\u001b[43m,\u001b[49m\u001b[43mInterval\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mRopen\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m4\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m8\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/Documents/packaging_tutorial/src/function_calculator_package/extreme_points.py:43\u001b[0m, in \u001b[0;36mfunction_monotonyset\u001b[0;34m(f, x, interval, dir)\u001b[0m\n\u001b[1;32m     39\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m     40\u001b[0m \u001b[38;5;124;03mcheck the sets if we can handle it.\u001b[39;00m\n\u001b[1;32m     41\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m     42\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m(zero_points_set\u001b[38;5;241m==\u001b[39mEmptySet):\n\u001b[0;32m---> 43\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m(\u001b[43minterval_inf_value\u001b[49m\u001b[38;5;241;43m<\u001b[39;49m\u001b[43minterval_sup_value\u001b[49m):\n\u001b[1;32m     44\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m  {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m+\u001b[39m\u001b[38;5;124m\"\u001b[39m:Interval\u001b[38;5;241m.\u001b[39mopen(interval\u001b[38;5;241m.\u001b[39minf,interval\u001b[38;5;241m.\u001b[39msup),\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m\"\u001b[39m:decrease_sets}\n\u001b[1;32m     45\u001b[0m     \u001b[38;5;28;01melse\u001b[39;00m:\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/core/decorators.py:236\u001b[0m, in \u001b[0;36m_SympifyWrapper.make_wrapped.<locals>._func\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m    234\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(other, expectedcls):\n\u001b[1;32m    235\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m retval\n\u001b[0;32m--> 236\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mother\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/core/expr.py:370\u001b[0m, in \u001b[0;36mExpr.__lt__\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m    367\u001b[0m \u001b[38;5;129m@sympify_return\u001b[39m([(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mother\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mExpr\u001b[39m\u001b[38;5;124m'\u001b[39m)], \u001b[38;5;28mNotImplemented\u001b[39m)\n\u001b[1;32m    368\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__lt__\u001b[39m(\u001b[38;5;28mself\u001b[39m, other):\n\u001b[1;32m    369\u001b[0m     \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mrelational\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m StrictLessThan\n\u001b[0;32m--> 370\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mStrictLessThan\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mother\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.9/site-packages/sympy/core/relational.py:834\u001b[0m, in \u001b[0;36m_Inequality.__new__\u001b[0;34m(cls, lhs, rhs, **options)\u001b[0m\n\u001b[1;32m    832\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m me \u001b[38;5;129;01min\u001b[39;00m (lhs, rhs):\n\u001b[1;32m    833\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m me\u001b[38;5;241m.\u001b[39mis_extended_real \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m:\n\u001b[0;32m--> 834\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid comparison of non-real \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m%\u001b[39m me)\n\u001b[1;32m    835\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m me \u001b[38;5;129;01mis\u001b[39;00m S\u001b[38;5;241m.\u001b[39mNaN:\n\u001b[1;32m    836\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid NaN comparison\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "\u001b[0;31mTypeError\u001b[0m: Invalid comparison of non-real zoo"
     ]
    }
   ],
   "source": [
    "function_monotonyset(expr,x,Interval.Ropen(4,8))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "5273bbc2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "403.3333333333333"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2000/24+320"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "083b753c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\frac{27 x}{10} + 128 - \\frac{1000}{3 x}$"
      ],
      "text/plain": [
       "-27*x/10 + 128 - 1000/(3*x)"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr=-1000/(S(3)*x)-27/S(10)*x+128\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "e5145bb2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{22439}{330}$"
      ],
      "text/plain": [
       "22439/330"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,11)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "5481c3de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{3052}{45}$"
      ],
      "text/plain": [
       "3052/45"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,12)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "b0fb083c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{True}$"
      ],
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,12)>65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "76e4ee1f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{True}$"
      ],
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs(x,11)>expr.subs(x,12)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "3b3bf482",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 19.6086417755051$"
      ],
      "text/plain": [
       "19.6086417755051"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(20*pi/(1.85*sqrt(3)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "38968067",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 19.6219340728011$"
      ],
      "text/plain": [
       "19.6219340728011"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(20*3.14/(1.85*1.73))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "52b6ac96",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[-1, 2\\right]$"
      ],
      "text/plain": [
       "Interval(-1, 2)"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A=Interval(-1,2)\n",
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "7b2f7348",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\frac{1}{2}, 4\\right]$"
      ],
      "text/plain": [
       "Interval(1/2, 4)"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B=function_range(2**x,x,A)\n",
    "B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "1a1911f3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\frac{1}{2}, 2\\right]$"
      ],
      "text/plain": [
       "Interval(1/2, 2)"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B.intersect(A)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "e1045e82",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 41.7891365572046$"
      ],
      "text/plain": [
       "41.7891365572046"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(log(3.8*10**12,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "0c76fa7a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle -32.4417721860487$"
      ],
      "text/plain": [
       "-32.4417721860487"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(20*log(3/(40*pi),10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "5e331c3d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[1, \\frac{5}{3}\\right)$"
      ],
      "text/plain": [
       "Interval.Ropen(1, 5/3)"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "continuous_domain(sqrt(ln(x))+log(5-3*x,10),x,Reals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "8dbb6433",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'+': [Interval.open(1, oo)], '-': [Interval.open(-oo, 1)]}"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_monotonyset(ln(x+2)+ln(4-x),x,Reals)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  },
  "toc-autonumbering": false,
  "toc-showcode": true,
  "toc-showmarkdowntxt": false,
  "toc-showtags": false
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
